我在一个页面上有两个网格都是独立的,但是当我对一个网格进行排序时,页面会刷新并在其他网格消息上进行排序。
我使用过更新面板但仍然不能正常工作...... 请帮帮我...
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<table>
<tr>
<td>
<asp:TextBox ID="txt1" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="grvDemo" runat="server" AllowSorting="true" AutoGenerateColumns="true" EnableSortingAndPagingCallbacks="TRUE">
</asp:GridView>
</ContentTemplate>
<Triggers> <asp:AsyncPostBackTrigger ControlID="grvDemo" EventName="grvDemo_Sorting" /> </Triggers>
</asp:UpdatePanel>
</td>
<td>
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AllowSorting="true" AutoGenerateColumns="true" EnableSortingAndPagingCallbacks="TRUE">
</asp:GridView>
</ContentTemplate>
<Triggers><asp:AsyncPostBackTrigger ControlID="GridView1" EventName="GridView1_Sorting" /></Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
</div>
</form>
代码:
Partial Class Import_ETL_Popup
Inherits Syscon.Web.UI.Page.baseClass
Protected Sub Page_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
bindgrid()
End Sub
Public Function bindgrid()
Dim dt As DataTable = DBHelper.ExecuteDataset(FunctionFactory.GetConnectionString(), CommandType.Text, "select user_name,password from tbl_user_mst").Tables(0)
grvDemo.DataSource = dt
grvDemo.DataBind()
Dim dt1 As DataTable = DBHelper.ExecuteDataset(FunctionFactory.GetConnectionString(), CommandType.Text, "select password,user_name from tbl_user_mst order by user_name").Tables(0)
GridView1.DataSource = dt1
GridView1.DataBind()
End Function
Protected Sub grvDemo_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles grvDemo.Sorting
Dim dt As DataTable = DBHelper.ExecuteDataset(FunctionFactory.GetConnectionString(), CommandType.Text, "select user_name,password from tbl_user_mst order by user_name desc").Tables(0)
grvDemo.DataSource = dt
grvDemo.DataBind()
End Sub
Protected Sub GridView1_Sorting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSortEventArgs) Handles GridView1.Sorting
Dim dt1 As DataTable = DBHelper.ExecuteDataset(FunctionFactory.GetConnectionString(), CommandType.Text, "select password,user_name from tbl_user_mst order by user_name desc").Tables(0)
GridView1.DataSource = dt1
GridView1.DataBind()
End Sub
End Class
答案 0 :(得分:0)
您在EventName
控件中提供了错误的UpdatePanel
有关此主题的更多信息Go here
实际上,您不必在EventName
控件的UpdatePanel
属性中提供事件处理程序,您只需要提供事件的名称,例如click
是名称由按钮控件提供的事件。
答案 1 :(得分:0)
试试这个
<asp:AsyncPostBackTrigger ControlID="grvDemo" EventName="OnSorting" />
和这个
<asp:AsyncPostBackTrigger ControlID="GridView1" EventName="OnSorting" />