I am looking for a solution to load my gridview using ajax situation is like this below, gridview is populated with already existing files in a folder and when a user upload another file that file also need to populate on the gridview using ajax. I am using asp.net c# jquery Gridview contains 3 columns one for filename ie,boundfiled and 2 other template field for download and delete. How can i done please help me.
<div id="dvListFiles">
<wuc:EmptyGridView ID="GridView1" runat="server" AutoGenerateColumns="false" ShowEmptyTable="False">
<Columns>
<asp:BoundField DataField="Text" HeaderText="File Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkDownload" Text = "Download" CommandArgument = '<%# Eval("Value") %>' runat="server" OnClick = "DownloadFile"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID = "lnkDelete" Text = "Delete" CommandArgument = '<%# Eval("Value") %>' runat = "server" OnClick = "DeleteFile" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</wuc:EmptyGridView>
c# code
string path =Configuration.DocumentationFileUploadLocation;
if (Session["CaseNumber"] != "")
path = path + "/" + Session["CaseNumber"];
else
{
path = path + "/" + HttpContext.Current.Session.SessionID;
}
if (Directory.Exists(path))
{
string[] filePaths = Directory.GetFiles(path);
List<ListItem> files = new List<ListItem>();
foreach (string filePath in filePaths)
{
files.Add(new ListItem(Path.GetFileName(filePath), filePath));
}
GridView1.DataSource = files;
GridView1.DataBind();
}
Thanks Alex