Reputation: 3751
I have a button in a GridView inside an UpdatePanel.
I get the following error when I run the page:
A control with ID 'btnShowDepend' could not be found for the trigger in UpdatePanel 'TasksUpdatePanel'.
How do I resolve the issue.
Upvotes: 1
Views: 789
Reputation: 5269
You better add your async trigger in the RowDataBound
event:
void yourTasksGV_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
ImageButton ib = e.Row.FindControl("btnShowDepend") as ImageButton;
if (ib != null)
{
AsyncPostBackTrigger trigger = new AsyncPostBackTrigger();
trigger.ControlID = ib.UniqueID;
trigger.EventName = "Click";
TasksUpdatePanel.Triggers.Add(trigger);
}
}
}
Upvotes: 2
Reputation: 1515
you need to register that Image button as an AsyncPostbackTrigger.
Try this one in RowDataBound
protected void yourTasksGV_RowDataBound(object sender, GridViewRowEventArgs
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
ImageButton ib = e.Row.FindControl("btnShowDepend") as ImageButton;
ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(ib);
}
}
Upvotes: 2
Reputation: 1515
Add one more updatepanel within ContentTemplate
<asp:UpdatePanel ID="updButton" runat="server" UpdateMode="Conditional">
<asp:ImageButton ID="btnShowDepend" runat="server" OnCommand="btnShowDepend_Command" />
</ContentTemplate>
Upvotes: 2
Reputation: 69
Button btnShowDepend=(Button)TasksUpdatePanel.FindControl("btnShowDepend");
Please use this
Or Maybe you have to put btnShowDepend out of updatepanel
Upvotes: 2