2012-07-19 26 views
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 

回答

0

你在你的UpdatePanel控件提供錯誤EventName

對於該主題的更多信息Go here

其實你不必在你的UpdatePanel控件的EventName屬性中提供事件處理程序,你只需要提供像click這樣的事件的名稱是由按鈕控件提供的事件的名稱。

0

試試這個

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

<asp:AsyncPostBackTrigger ControlID="GridView1" EventName="OnSorting" /> 
相關問題