0

我在一页上有两个网格,它们都是独立的,但是当我对一个网格进行排序时,页面会刷新并在其他网格上排序消失。

我已经使用了更新面板,但仍然无法正常工作...请帮助我...

<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
4

2 回答 2

0

尝试这个

 <asp:AsyncPostBackTrigger ControlID="grvDemo" EventName="OnSorting" />

和这个

<asp:AsyncPostBackTrigger ControlID="GridView1" EventName="OnSorting" />
于 2012-07-19T11:07:24.097 回答
0

EventName您在UpdatePanel控件中提供错误

有关此主题的更多信息,请转到此处

实际上,您不必在控件的该EventName属性中提供事件处理程序UpdatePanel,您只需要提供事件的名称,就像click按钮控件提供的事件的名称一样。

于 2012-07-19T11:00:34.077 回答