在更新面板中无法刷新网格 [英] Not able to refresh the grid when in update panel
问题描述
Gridview pageindex更改事件会触发但它不刷新网格值,
-Gridview处于模态弹出状态,因此我不想刷新整个页面。
Gridview pageindex change event gets fire but its not refresh the grid values,
-Gridview is in modal pop up, therefore i dont want to refresh whole page.
< asp:updatepanel id =UpdatePanel1runat = serverupdatemode =条件childrenastriggers =false>
< contenttemplate>
< asp:gridview id =gvEmployeeListrunat =serverallowpaging =Trueautogeneratecolumns =False
=cssclass =table table-有条纹的表格行emptydatatext =记录不可用!!! headerstyle-height =30pagesize =5width =100%onpageindexchanging =gvEmployeeList_PageIndexChangingdatakeynames =EMP_IDenableortingandpagingcallbacks =true>
< columns>
< asp:templatefield headertext =Select>
< headertemplate>
< asp:checkbox id =chkHeaderEmprunat =服务器>
< itemtemplate>
< asp:checkbox id =chkChildrunat =server>
< asp:label id =lblIdrunat =servertext =<%#Bind(EMP_ID)%>可见= 假 >
< itemstyle horizontalalign =Centerverticalalign =Middle>
< asp :templatefield headertext =不。 itemstyle-width =20px>
< itemtemplate>
< asp:label runat =serverid =lblSlNo><%# Container.DataItemIndex + 1%>
< headerstyle horizontalalign =Left>
< itemstyle horizontalalign =Left >
< asp:templatefield>
< headertemplate>
员工姓名
< itemtemplate>
< asp:label id =lblFullName runat =servertext =<%#bind(EMP_NAME)%>>
< asp:templatefield headertext =Departmentitemstyle-width =20px>
< itemtemplate>
< asp:label id =lblDPT_DESCRrunat = servertext =<%#Bind(DPT_DESCR)%>>
< asp:label id =lblDPT_IDrunat =servertext =<% #Bind(DPT_ID)%> visible =false>
< headerstyle horizontalalign =Left>
< itemstyle horizontalalign =Left> ;
< asp:templatefield headertext =包含在工作流程中itemstyle-width =20px>
< itemtemplate>
< asp:checkbox id =chkIncludeInWorkFlowrunat =server>
< headerstyle horizontalalign =Left>
< itemstyle horizontalalign =Left>
< rowstyle cssclass =griditemheight =25px>
< selectedrowstyle backcolor =Aqua> ;
< headerstyle cssclass =gridheader_popheight =25px>
< alternatingrowstyle cssclass =griditem_alternative>
<触发器>
< asp:asyncpostbacktrigger controlid =gvEmployeeListeventname =PageInd交换>
<asp:updatepanel id="UpdatePanel1" runat="server" updatemode="Conditional" childrenastriggers="false">
<contenttemplate>
<asp:gridview id="gvEmployeeList" runat="server" allowpaging="True" autogeneratecolumns="False"
="" cssclass="table table-bordered table-row" emptydatatext="Record not available !!!" headerstyle-height="30" pagesize="5" width="100%" onpageindexchanging="gvEmployeeList_PageIndexChanging" datakeynames="EMP_ID" enablesortingandpagingcallbacks="true">
<columns>
<asp:templatefield headertext="Select">
<headertemplate>
<asp:checkbox id="chkHeaderEmp" runat="server">
<itemtemplate>
<asp:checkbox id="chkChild" runat="server">
<asp:label id="lblId" runat="server" text="<%# Bind("EMP_ID") %>" visible="false">
<itemstyle horizontalalign="Center" verticalalign="Middle">
<asp:templatefield headertext="No." itemstyle-width="20px">
<itemtemplate>
<asp:label runat="server" id="lblSlNo"><%# Container.DataItemIndex + 1 %>
<headerstyle horizontalalign="Left">
<itemstyle horizontalalign="Left">
<asp:templatefield>
<headertemplate>
Employee Name
<itemtemplate>
<asp:label id="lblFullName" runat="server" text="<%# bind("EMP_NAME") %>">
<asp:templatefield headertext="Department" itemstyle-width="20px">
<itemtemplate>
<asp:label id="lblDPT_DESCR" runat="server" text="<%# Bind("DPT_DESCR")%>">
<asp:label id="lblDPT_ID" runat="server" text="<%# Bind("DPT_ID")%>" visible="false">
<headerstyle horizontalalign="Left">
<itemstyle horizontalalign="Left">
<asp:templatefield headertext="Include in Workflow" itemstyle-width="20px">
<itemtemplate>
<asp:checkbox id="chkIncludeInWorkFlow" runat="server">
<headerstyle horizontalalign="Left">
<itemstyle horizontalalign="Left">
<rowstyle cssclass="griditem" height="25px">
<selectedrowstyle backcolor="Aqua">
<headerstyle cssclass="gridheader_pop" height="25px">
<alternatingrowstyle cssclass="griditem_alternative">
<triggers>
<asp:asyncpostbacktrigger controlid="gvEmployeeList" eventname="PageIndexChanging">
-----------------代码背后------------
受保护的子gvEmployeeList_PageIndexChanging(ByVal sender As Object,ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs)
gvEmployeeList.PageIndex = e.NewPageIndex
bindEmployeeGrid_More( )
UpdatePanel1.Update()
结束次级
我尝试过的事情:
我几乎尝试过所有事情。我尝试了更多面板和gridview属性的许多选项。
-----------------Code behind------------
Protected Sub gvEmployeeList_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs)
gvEmployeeList.PageIndex = e.NewPageIndex
bindEmployeeGrid_More()
UpdatePanel1.Update()
End Sub
What I have tried:
I tried almost everything. I tried many option available with update panel and gridview properties.
推荐答案
尝试执行以下操作:
1.在UpdatePanel中删除ChildrenAsTrigger =false。
2.删除< trigger>声明。
3.删除UpdatePanel1.Update()方法。
基本思路是将GridView和Modal声明包装在里面UpdatePanel控件。例如:
Try to do the following:
1. Remove the ChildrenAsTrigger="false" in your UpdatePanel.
2. Remove the <trigger> declaration.
3. Remove the UpdatePanel1.Update() method.
The basic idea is to just wrap your GridView and Modal declaration inside UpdatePanel control. For example:
<asp:Button ID="hiddenButton" runat="server" Text="" style="display:none;" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" Enabled="True" TargetControlID="hiddenButton" PopupControlID="upModal" BehaviorID="modalbehavior" BackgroundCssClass="modalBackground" OnCancelScript="cancelClick();" CancelControlID="closePopup">
</ajaxToolkit:ModalPopupExtender>
<asp:UpdatePanel runat="server" ID="upModal" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel id="pnlPopup" runat="server" class="ModalPanel" >
<table cellpadding="5" cellspacing="5" class="topBanner" style="width:100%;">
<tr>
<td width="50">
<asp:LinkButton ID="closePopup" runat="server" onclick="LinkButton1_Click" CssClass="ClosePopupCls">Close
[x]</asp:LinkButton>
</td>
<td align="center">
<asp:Label ID="lbl" runat="server" Text="Status"></asp:Label>
</td>
<td width="25">
</td>
</tr>
<tr>
<td colspan="3">
<asp:GridView ID="gvRecords" runat="server" AllowPaging="True"
BackColor="White" EmptyDataText="No Record Found"
EnableSortingAndPagingCallbacks="True" ForeColor="GrayText" Height="600"
onpageindexchanging="gvRecords_PageIndexChanging" Width="800">
</asp:GridView>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
然后打开GridView,你可以这样做(注意这是在C#中):
Then to open the GridView, you could do something like this (Note that this is in C#):
protected void btnShowGridView_Click(object sender, EventArgs e)
{
ModalPopupExtender1.Show();
BindData();
}
您的PageIndexChanging事件将是这样的:
Your PageIndexChanging event would be like this:
protected void gvRecords_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvRecords.PageIndex = e.NewPageIndex;
BindData();
}
这篇关于在更新面板中无法刷新网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!