开发者

How to prevent Postback on GridView paging in UpdatePanel

开发者 https://www.devze.com 2023-01-31 15:21 出处:网络
I have apply paging in GridView which is in UpdatePanel.When I move forward to the next result set full Postback occur on my Page.Do i need to do some modification in web.config file or in my code.

I have apply paging in GridView which is in UpdatePanel.When I move forward to the next result set full Postback occur on my Page.Do i need to do some modification in web.config file or in my code.

 [ ASPX ]
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
    <asp:GridView ID="gvCommentSample" runat="server" 
OnPageIndexChanging="gvCommentSample_PageIndexChanging" AllowPaging="true" PageSize="2"
ShowFooter="false" Width="100%" ShowHeader="false" BorderWidth="0px" >
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>

[ CODE BEHIND ]
Dim table As DataTable

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 If Not IsPostBack Then
    bindGridView()
 End If
End Sub
    Private Function GetTable() As DataTable
        table = New DataTable()
        table.Columns.Add("FirstName")
        table.Columns.Add("LastName")

        Dim row As DataRow = table.NewRow()
        row("FirstName") = "John"
        row("LastName") = "Johnoson"
        table.Rows.Add(row)

        row = table.NewRow()
        row("FirstName") = "Johnny"
        row("LastName") = "Marley"
        table.Rows.Add(row)

        row = table.NewRow()
        row("FirstName") = "Kate"
        row("LastName") = "Li"
        table.Rows.Add(row)

        Return table
    E开发者_JS百科nd Function
    Public Sub bindGridView()
        gvCommentSample.DataSource = GetTable()
        gvCommentSample.DataBind()
    End Sub
    Protected Sub gvCommentSample_PageIndexChanging(ByVal sender As Object, ByVal e As GridViewPageEventArgs)
        Dim gvCommentSample As GridView = DirectCast(sender, GridView)
        gvCommentSample.PageIndex = e.NewPageIndex
        gvCommentSample.DataSource = GetTable()
        gvCommentSample.DataBind()
    End Sub


I got the solution. I have to put

<xhtmlConformance mode="Transitional"/> 

element in web.Config file.


this entry we have to do under syste.web, but it didnt work ou for me. i m using the grid in MOSS. after this entry full post back was done again


I have a similar issue. Its solved by using The real problem is I have used tdXXXXX = de('_ctl0_CPB_XXXXX');

where de is a function function de(clID)

        {
            return document.getElementById(clID);  
        }       

Previously the control was rendered correctly as _ctl0_CPB_XXXXX, now it has appeneded an extra 0 ie. _ctl00_CPB_XXXXX. This is used throught the application, and its causing the javaScripts failures. Any solutions.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号