C# GridView中的文件上载控件
我在GridViewControl中有两个用于上载文件的文件上载控件,我在gridview中有一个用于上载文件的按钮,我使用它的RowCommandEvent来上载文件。如何在RowCommandEvent中获取fileupload控件的值? 这是我的网格视图C# GridView中的文件上载控件,c#,asp.net,C#,Asp.net,我在GridViewControl中有两个用于上载文件的文件上载控件,我在gridview中有一个用于上载文件的按钮,我使用它的RowCommandEvent来上载文件。如何在RowCommandEvent中获取fileupload控件的值? 这是我的网格视图 <asp:GridView ID="DgFiles" runat="server" AutoGenerateColumns="false" OnRowCommand="DgFiles_RowCommand">
<asp:GridView ID="DgFiles" runat="server" AutoGenerateColumns="false" OnRowCommand="DgFiles_RowCommand">
<Columns>
<asp:TemplateField HeaderText="Crime" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="category" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Category") %>' ></asp:Label><br/>
<asp:FileUpload ID="file1" runat="server" /><br />
<asp:FileUpload ID="file2" runat="server" />
<asp:Button ID="btnupload" runat="server" CommandName="upload" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lbldate" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "Date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Label ID="lblcity" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "City") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
我必须以类似GridView的结构显示记录,其中包含文件上载控件,如果有其他方法,请建议。首先,您必须添加一个命令名为upload的命令列
第二
必须使用父属性在行内找到控件
FileUpload fl1 = (FileUpload)e.Row[rowindex].Cells<cellindex>.FindControl("File1")
FileUpload fl2 = (FileUpload)e.Row[rowindex].Cells<cellindex>.FindControl("File2")
FileUpload fl1=(FileUpload)e.Row[rowindex].Cells.FindControl(“File1”)
FileUpload fl2=(FileUpload)e.Row[rowindex].Cells.FindControl(“File2”)
现在您可以使用
fl1
和fl2
作为文件控件 我看到了这个,这个控件有一个上传控件,我对每一行都有单独的控件
FileUpload fl1 = (FileUpload)e.Row[rowindex].Cells<cellindex>.FindControl("File1")
FileUpload fl2 = (FileUpload)e.Row[rowindex].Cells<cellindex>.FindControl("File2")