Hello Experts,
I am having file upload control in gridview and girdview is in update panel.
I have gridview soem thing like this
Name description Image Edit
Now on clicking edit it allows user to change name, description and image. for image I have used file upload control but as it is in update pane, while clicking update it shows fileupload.hasfile = flase. I need to reqired post back trigger in update panel
trigger section but how to add the update button trigger in it?
Please help.
Thank you.
Fileupload control doesn't work with update panel in a gridview.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
FileUpload fu = (FileUpload)e.Row.FindControl("FileUpload1");
ScriptManager.GetCurrent(this).RegisterPostBackControl(fu);
}
Hope this helps...
Hello Vipin,
Thanks for replay. This won't work. The file upload control is available at edit template not in row data binding. also I guess we need to bind the trigger to update link button of edit command.
Thanks all, got the solution
protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if((e.Row.RowState & DataControlRowState.Edit) > 0)
{
LinkButton lb = e.Row.Controls[4].Controls[0] as LinkButton;
if(lb != null)
ScriptManager.GetCurrent(this).RegisterPostBackControl(lb);
}
}
}
沒有留言:
張貼留言