Sunday, March 8, 2009

Codeless sorting/paging GridView in asp.net




Please visit my new Web Site WWW.Codedisplay.com



Atfirst this post is only for beginner. Here i am introducing the most popular control in asp.net is GridView. A tremendous improvement over asp. Do you think that without writng a single line of code you can present a page with sorting & paging facility? Yes you can do it with few clicks just follow my below steps:

1) Modify your web.config file to write the connectionstring. Code should be:

<connectionStrings>
<
add name="TestConnection" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=TESTDB;Trusted_Connection=yes;" providerName="System.Data.SqlClient"/>
</
connectionStrings>


2) Add a SqlDataSource in your page & set the properties described in the following image to read data from your database.

















3) Now add a GridView control & set the DataSource property to the SqlDataSource. Alos check the Enable paging, Enable sorting CheckBox. Now your page looks like below.















Now run your page & click on the header for sorting & click on the page number for paging. You can set the PageSize properties of GridView that how many rows you want to display in one page. In the following image my PageSize is 3.









Read the below link for simple almost codeless Insert, Delete & Update operation on GridView control: http://shawpnendu.blogspot.com/2009/03/simple-quick-way-to-insertdeleteupdate.html

0 comments:

Want to say something?
I WOULD BE DELIGHTED TO HEAR FROM YOU

Want To Search More?
Google Search on Internet
Subscribe RSS Subscribe RSS
Article Categories
  • Asp.net
  • Gridview
  • Javascript
  • AJAX
  • Sql server
  • XML
  • CSS
  • Free Web Site Templates
  • Free Desktop Wallpapers
  • TopOfBlogs
     
    Free ASP.NET articles,C#.NET,VB.NET tutorials and Examples,Ajax,SQL Server,Javascript,Jquery,XML,GridView Articles and code examples -- by Shawpnendu Bikash