简体   繁体   English

为什么在更新面板中找不到控件

[英]Why is a control not found in an updatepanel

I have a button in a GridView inside an UpdatePanel. 我在UpdatePanel内的GridView中有一个按钮。

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. 我该如何解决该问题。

You better add your async trigger in the RowDataBound event: 您最好在RowDataBound事件中添加异步触发器:

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);
        }
    }
}
Button btnShowDepend=(Button)TasksUpdatePanel.FindControl("btnShowDepend");

Please use this 请用这个

Or Maybe you have to put btnShowDepend out of updatepanel 或者也许您必须将btnShowDepend放在updatepanel中

Add one more updatepanel within ContentTemplate ContentTemplate中再添加一个updatepanel

  <asp:UpdatePanel ID="updButton" runat="server" UpdateMode="Conditional"> <asp:ImageButton ID="btnShowDepend" runat="server" OnCommand="btnShowDepend_Command" /> </ContentTemplate> 

you need to register that Image button as an AsyncPostbackTrigger. 您需要将该图像按钮注册为AsyncPostbackTrigger。

Try this one in RowDataBound 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); } } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 UpdatePanel 中找不到触发器的 ID 控件 - A control with ID could not be found for the trigger in UpdatePanel 为什么未找到UpdatePanel来更新数据 - Why isn't the UpdatePanel found to update the data 在UpdatePanel&#39;pnlUpdate&#39;中找不到触发器ID为&#39;btnUpload&#39;的控件 - A control with ID 'btnUpload' could not be found for the trigger in UpdatePanel 'pnlUpdate' 在UpdatePanel&#39;UpdatePanel3&#39;中找不到触发器ID为&#39;imgbtn_excel_gridout&#39;的控件 - A control with ID 'imgbtn_excel_gridout' could not be found for the trigger in UpdatePanel 'UpdatePanel3' 为什么我收到此错误,在UpdatePanel中找不到触发器的ControlID? - Why I am getting this error ,ControlID could not be found for the trigger in UpdatePanel? 为什么updatepanel会触发另一个updatepanel? - Why updatepanel triggers another updatepanel? 使用第二个UpdatePanel的gridview中的LinkBut​​ton从第一个UpdatePanel更新文本框。 无法找到控制权 - Update textbox from 1st UpdatePanel using LinkButton from 2nd UpdatePanel's gridview. Control could not be found 更新UpdatePanel外部的控件 - Updating a control outside the UpdatePanel 带有AsyncPostback的UpdatePanel尝试在UpdatePanel外部更新控件 - UpdatePanel with AsyncPostback tryes to update control outside UpdatePanel 为什么updatepanel中的控件消失了? - why controls in updatepanel disappeared?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM