码迷,mamicode.com
首页 > 其他好文 > 详细

Full postback triggered by LinkButton inside GridView inside UpdatePanel

时间:2014-05-01 14:06:55      阅读:355      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   java   tar   javascript   ext   color   get   art   

GridView inside of a UpdatePanel,get the button to trigger a partial postback

mamicode.com,码迷
<asp:ScriptManager ID="ContentScriptManager" runat="server"/>
<asp:UpdatePanel ID="ContentUpdatePanel" runat="server"ChildrenAsTriggers="true">
    <ContentTemplate>
        <asp:GridView ID="OrderGrid" runat="server"AllowPaging="false"AllowSorting="false"
            AutoGenerateColumns="false">
            <Columns>
                <asp:TemplateFieldHeaderText="">
                    <ItemTemplate>
                        <asp:LinkButton ID="MarkAsCompleteButton" runat="server"Text="MarkAsComplete"
                            CommandName="MarkAsComplete"CommandArgument=<%# Eval("Id") %>/>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundFieldDataField="Name"HeaderText="Name"/>
                <asp:BoundFieldDataField="LoadDate"HeaderText="Load Date"/>
                <asp:BoundFieldDataField="EmployeeCutOffDate"HeaderText="Cut Off Date"/>
                <asp:BoundFieldDataField="IsComplete"HeaderText="Is Completed"/>
            </Columns>
        </asp:GridView>
    </ContentTemplate>
</asp:UpdatePanel>
mamicode.com,码迷

 

You need to register each and every LinkButton as an AsyncPostBackTrigger.  After each row is bound in your GridView, you‘ll need to search for the LinkButton and register it through code as follows:

protected void OrderGrid_RowDataBound(object sender, GridViewRowEventArgs e)  
{  
   LinkButton lb = e.Row.FindControl("MarkAsCompleteButton") as LinkButton;  
   ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(lb);  
}  


参考:

http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.childrenastriggers.aspx

http://stackoverflow.com/questions/4872210/full-postback-triggered-by-linkbutton-inside-gridview-inside-updatepanel

Full postback triggered by LinkButton inside GridView inside UpdatePanel,码迷,mamicode.com

Full postback triggered by LinkButton inside GridView inside UpdatePanel

标签:style   blog   class   code   java   tar   javascript   ext   color   get   art   

原文地址:http://www.cnblogs.com/KingStar/p/3700864.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!