Thursday, May 2, 2013

gridview paging and sorting without postback in

In previous articles we have seen Bind data to dropdownlist in gridview,edit,delete,update in grdivew.In this post i will show how to avoid the post back while doing the sorting and paging in gridview.For this we need the set the EnableSortingAndPagingCallbacks to true,then it can perform client side callbacks to fetch the data.If we are using Template field.This property can not support.

<html xmlns="" >
<title>Gridview Paging and Sorting with out postback</title>
<form id="form1" runat="server">
<asp:GridView ID="GvSales" AllowSorting="True" Runat="server"
 EnableSortingAndPagingCallbacks="true" AllowPaging="true" 
AutoGenerateColumns="False" DataSourceID="SalesDb" 
            <asp:BoundField DataField="SalesID" HeaderText="SalesID"
                 SortExpression="SalesID" />
             <asp:BoundField DataField="SalesPersonName" HeaderText="SalesPersonName"
                SortExpression="SalesPersonName" />
             <asp:BoundField DataField="SaleCity" HeaderText="SalesCity" SortExpression="SaleCity" />
             <asp:BoundField DataField="SalesAmt" HeaderText="Samount"
                 SortExpression="Samount" />
<asp:SqlDataSource ID="SalesDb" runat="server"
            ConnectionString="<%$ ConnectionStrings:bhaskarConnectionString %>"
            SelectCommand="SELECT * FROM [Sales_Orders]"></asp:SqlDataSource>
Paging and sorting in Gridview

No comments: