Click here to Skip to main content
15,908,455 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all
i have grid view placed one button and file upload control inside gridview when am clicking button i had written code like
protected void btnuploadimage_click(object sender, EventArgs e)
    {
        Button btngetpath = sender as Button;
        GridViewRow row = (GridViewRow)btngetpath.NamingContainer;
        FileUpload upctl = GridView1.Rows[row.RowIndex].Cells[5].FindControl("FileUpload4") as FileUpload;
if (upctl.HasFile)//here it show no file in fileupload and it going out side loop
        {

        }
    }

when am debugging it is finding control but not having file name has file is false
lot of people suffer with this problem how con i get file path here i tried in many ways but am not getting file in any way please kindly help me
thanks in advance
Posted
Updated 19-Jul-11 8:47am
v4
Comments
[no name] 19-Jul-11 8:32am    
is this button present in grid or it is outside the grid??
tulasiram3975 19-Jul-11 8:57am    
Button is Present in the Grid Only Both upload control and button kept in single cell
tulasiram3975 19-Jul-11 8:42am    
Button is Present in the Grid Only Both upload control and button kept in single cell
Al Moje 20-Jul-11 4:45am    
Hi,

You must not FinControl inside the row grid Cell.

the right way is, You could FinControl in a grid row.

You can do this way:

FileUpload upctl = GridView1.Rows[row.RowIndex].Cells[5].Text as FileUpload;

or you could cast as below:

FileUpload upctl = (FileUpload)GridView1.Rows[row.RowIndex].Cells[5].Text;

You had posted this two times. First you manipulate
inside GridView1_RowCommand.

Now you change it and trying to manipulate in
btnuploadimage.

I had tested my first solution answer and is working...
maybe you did not test it.

Please be Advise you to be consistent...

1 solution

Hi,

See this link
how to manage file upload control inside grid view

Regards,

Algem
 
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