如何分配的UpdatePanel触发控制ID与键的距离GridView控件 [英] How to assign UpdatePanel Trigger's control ID with button's from gridview

查看:128
本文介绍了如何分配的UpdatePanel触发控制ID与键的距离GridView控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我有一个UpdatePanel的jQuery的对话框使用,其中包含一个GridView。

currently I have a UpdatePanel for jQuery Dialog use, which contains a GridView.

这GridView控件包含页脚和EmptyDataTemplate一个FileUpload控件

And that GridView contains a FileUpload control in footer and EmptyDataTemplate

为了获得在javascript中FileUpload控件的工作,我知道,我们需要触发。

In order to get FileUpload control work in javascript, I know that we need trigger.

不过,我想指定为触发GridView的模板内的按钮...

However, the button that I wanna assign as trigger is inside GridView's template...

当按钮点击btnAdd,文件中FileUpload控件将被保存。

when the button btnAdd clicked, file in FileUpload control will be saved.

下面是code:

<asp:UpdatePanel ID="upnlEditExpense" runat="server">
      <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnAdd"/>
      </Triggers>
            ......................
                 ........................
                       .........................
      <asp:GridView runat="server" ID="grdExpense" ShowHeader="True" ShowFooter="True"
           AutoGenerateColumns="False">
           <Columns>
                 ...................
                 <asp:TemplateField>
                       <FooterTemplate>
                              <asp:LinkButton runat="server" ID="btnAdd" Text="Add" OnClick="btnAdd_Click"></asp:LinkButton>
                       </FooterTemplate>
                 </asp:TemplateField>
           </Columns>
      </asp:GridView>
</asp:UpdatePanel>

如果我直接把按钮的ID在这样的触发器的控件的ID,错误想出说btnAdd找不到...

If I put the button id directly in trigger's control ID like this, error come up saying btnAdd could not be found...

是我应该做的就是FileUpload控件的工作?

what should I do to get FileUpload control work?

推荐答案

这工作

protected void grdExpense_RowCreated(object sender, GridViewRowEventArgs e)
    {
        LinkButton btnAdd = (LinkButton)e.Row.Cells[0].FindControl("btnAdd");
        if (btnAdd != null)
        {
            ScriptManager.GetCurrent(this).RegisterPostBackControl(btnAdd);
        }

    }

这篇关于如何分配的UpdatePanel触发控制ID与键的距离GridView控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆