我想要发生的是显示上传的文件在网格视图(工作正常),并发送相同的文件到SQL数据库(工作正常)。文件上传发送到数据库,并立即显示到gridview
我的主要任务是获取当前登录人员下的所有上传文件,例如customerA登录,仅显示客户A的上传文件。
具有在我的数据库,我现在实现一个select语句。 (这里是我的问题开始的地方),这里是页面加载代码:
public static string cs = "Server=PAULO;Database=ShoppingCartDB;Integrated Security=true";
protected void Page_Load(object sender, EventArgs e)
{
if (Session["New"] != null)
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection(cs);
con.Open();
string sql = "SELECT * FROM DepositSlip Where Username = '" + Session["New"] + "'";
SqlDataAdapter da = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable();
da.Fill(dt);
Label2.Text += Session["New"].ToString();
linkLogout.Visible = true;
linkOrderHistory.Visible = true;
Label2.Visible = true;
linkViewProfile.Visible = true;
string[] filePaths = Directory.GetFiles(Server.MapPath("~/Uploads/"));
List<ListItem> files = new List<ListItem>();
foreach (string filePath in filePaths)
{
files.Add(new ListItem(Path.GetFileName(filePath), filePath));
}
GridView1.DataSource= files;
GridView1.DataBind();
}
}
}
据我所知,它装载了从目录路径的文件,但我不知道是如何实现显示上传的文件从基于会话用户的数据库中获取。
的问题是不管它显示了谁登录了相同的数据。
对此有什么技巧?