Prakash Mondal

Prakash Mondal

  • NA
  • 288
  • 209.4k

How to use FileUpload inside GridView inside UpdatePannel??

Apr 18 2013 12:16 PM
How to use FileUpload control inside Gridview inside UpdatePanel use LinkButton or ImageButton use GridView1_RowUpdating Even or LinkButton1_Click Even????

My problem is Filename ="" and HasFile=false;


My design is: 


Design Code:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                                DataKeyNames="username" onrowupdating="GridView1_RowUpdating"
                                onrowcancelingedit="GridView1_RowCancelingEdit"
                                onrowediting="GridView1_RowEditing">
                                <Columns>
                                    <asp:TemplateField HeaderText="Operations">
                                        <EditItemTemplate>
                                            <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Update">Update</asp:LinkButton>
                                            &nbsp;<asp:LinkButton ID="LinkButton3" runat="server" CommandName="Cancel">Cancel</asp:LinkButton>
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:LinkButton ID="LinkButton1" runat="server" CommandName="EDIT">Edit</asp:LinkButton>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="Username" HeaderText="Username" />
                                    <asp:TemplateField HeaderText="Bio-Data">
                                        <EditItemTemplate>
                                            <asp:FileUpload ID="FileUpload1" runat="server" />
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="Label2" runat="server" Text='<%#Eval("biodata") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:GridView>
                            <br />
                            <asp:ScriptManager ID="ScriptManager1" runat="server">
                            </asp:ScriptManager>
                            <br />
                            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                        </ContentTemplate>
                    </asp:UpdatePanel>

Then Run this File:



.cs Code:====



And Also I want to Try this............

 protected void LinkButton2_Click(object sender, EventArgs e)
    {
        LinkButton btn = sender as LinkButton;
        GridViewRow gvr = (GridViewRow)btn.NamingContainer;
        FileUpload flup = GridView1.Rows[gvr.RowIndex].FindControl("FileUpload1") as FileUpload;
        string file = flup.FileName;
    }

But same problem....

Please solve my problem....


Answers (6)