请帮助解决这些问题;
我在Itemtemplate中有一个带有AjaxFileupload的gridview。在每行中使用AjaxFileUpload填充gridview并上载文件之后。我需要通读gridview并在bujtton点击获取文件名。请在下面找到代码
<div>
<asp:GridView ID="grdView_Requirement" runat="server" AutoGenerateColumns="False" Font-Names="Segoe UI" Font-Size="12px">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" />
<asp:TemplateField HeaderText="Upload File">
<ItemTemplate>
<asp:AjaxFileUpload ID="AjaxFileUploadNew" runat="server" Font-Names="Segoe
UI" Font-Size="12px" MaximumNumberOfFiles="1" Width="388px" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
</Columns>
<FooterStyle BackColor="#5D7B9D" ForeColor="#333333" />
<HeaderStyle BackColor="#D7D9E5" ForeColor="#333333" />
<RowStyle BackColor="#FFFFFF" ForeColor="#333333" />
</asp:GridView>
</div>
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
上传代码
protected void AjaxFileUploadNew_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string strLongFilePath = e.FileName;
string strFileExtension = System.IO.Path.GetExtension(strLongFilePath);
char[] ch = new char[] { '\\' };
string[] strPath = strLongFilePath.Split(ch);
string strInternalFileName = DateTime.Now.ToFileTime().ToString() + strFileExtension;
string strDestPath = Server.MapPath("~/UploaderTemp/");
AjaxFileUploadNew.SaveAs(@strDestPath + strInternalFileName);
//Save path, filename to database here
}
请帮助在下面的事件中获取上传的文件名
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in grdView_Requirement.Rows)
{
//for bound field
string str = row.Cells[0].Text.ToString();
//for templated control
AjaxControlToolkit.AjaxFileUpload tb = row.FindControl("AjaxFileUploadNew") as
AjaxControlToolkit.AjaxFileUpload;
}
}
请帮助解决或提供更好的实施方法,以取得成功。