首页 > 代码库 > Full postback triggered by LinkButton inside GridView inside UpdatePanel
Full postback triggered by LinkButton inside GridView inside UpdatePanel
GridView inside of a UpdatePanel,get the button to trigger a partial postback
<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>
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。