我在一页上有两个网格,它们都是独立的,但是当我对一个网格进行排序时,页面会刷新并在其他网格上排序消失。
我已经使用了更新面板,但仍然无法正常工作...请帮助我...
<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