【发布时间】:2015-04-11 03:42:24
【问题描述】:
好的,我有一个看起来像这样的 vb gridview:
<asp:GridView ID="grvMain" Width="100%" runat="server">
<Columns>
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Panel ID="pnlEdit" runat="server" Visible="False" Font-Size="15px">
<asp:AjaxFileUpload OnUploadComplete="AjaxFileUploadEvent" ID="AjaxFileUpload11" runat="server" MaximumNumberOfFiles="1" />
</asp:Panel>
<asp:LinkButton CommandArgument="<%# Container.DataItemIndex %>" ID="lbtnIcon" runat="server">View</asp:LinkButton>
</ItemTemplate>
<ItemStyle />
</asp:TemplateField>
</Columns>
</asp:GridView>
页面的其余部分无关紧要,但我确实拥有使 ajaxFileUpload 工作的所有代码。我遇到的问题是当文件上传在gridview中时,它不会调用它在gridview之外调用的事件。
这是我的 Gridview 的代码。
Public Sub grvMain_RowCommand(sender As Object, e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles grvMain.RowCommand
Dim intIndex As Integer = Convert.ToInt32(e.CommandArgument)
Dim pnlEdit As Panel = grvMain.Rows(intIndex).FindControl("pnlEdit")
pnlEdit.visible = true
End Sub
因此,当在 gridview 中按下链接按钮时,它会启用包含文件上传的面板。
OnUploadComplete 事件的代码是:
Sub AjaxFileUploadEvent(sender As Object, e As System.EventArgs)
Dim filename As String = System.IO.Path.GetFileName(e.FileName)
Dim strUploadPath As String = "~/images/"
AjaxFileUpload11.SaveAs(Server.MapPath(strUploadPath) + filename)
End Sub
代码所做的只是将文件保存在文件夹中。我还尝试将 ajaxfileupload 更改为OnClientUploadComplete="AjaxFileUploadEvent",但它仍然没有调用该事件。我只需要知道如何让它调用正确的事件,而不是仅仅进行回发。谢谢
【问题讨论】:
标签: c# asp.net vb.net gridview