Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi .,
Can anyone send me a sample code for using the fileUpload control in the gridview insert and edit templates.,

Please its urgent.,

Thanks
Posted
Updated 24-Mar-11 23:54pm
v2

 
Share this answer
 
Sure...a sample code:
Use TemplateField column and in the Item Template put fileUpload control.
<asp:TemplateField>
    <ItemTemplate>
        <asp:FileUpload ID="FileUpload1" runat="server" />
    </ItemTemplate>
</asp:TemplateField>


Start from here...Try!
 
Share this answer
 
try this

protected void GridView1_RowInserting(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = (GridViewRow)GridView1.Rows[e.RowIndex];
           
              FileUpload fileUploadProductImage = (FileUpload)row.FindControl("YourFileUploadName");
                if (fileUploadProductImage.HasFile == true)
                    {
                       //[Your Code]
                    }
        }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900