Click here to Skip to main content
15,885,757 members
Articles / Web Development / ASP.NET
Article

Custom DataGrid for Alphabetic Paging

Rate me:
Please Sign up or sign in to vote.
2.14/5 (10 votes)
28 Feb 2006 31.8K   193   21   6
This custom DataGrid control provides alphabetic paging for a given column.

Sample Image - Custom_DataGrid_Control.jpg

Introduction

One of my most used ASP.NET control is DataGrid. Presenting data from tables is very easy and nice with only one exception - the page navigator. Showing only page numbers or only two links (to previous and next page) is insufficient for me, and completely inexplicable for my clients. So I decided to create DataGrid Server Control, the main task of which is to providing paging alphabetically.

Using the control

1. Copy CustDataGrid.dll in your web application bin folder.
2. Add  this line on top of your aspx page or add control in toolbox by customize toolbox and drop control on your page.

ASP.NET
<%@ Register TagPrefix="cc1" Namespace="CustDataGrid" 
                Assembly="CustDataGrid" %>

3. add control on your page in form tag
ASP.NET
<%cc1:myCustDG id="MyCustDG1" 
  style="Z-INDEX: 101; LEFT: 110px; POSITION: absolute; TOP: 26px" 
  runat="server" Height="167px" Width="286px" BackColor="Info">
    <AlternatingItemStyle BackColor="MistyRose"></AlternatingItemStyle>
    <FooterStyle Font-Bold="True" BackColor="LightPink"></FooterStyle>
    <HeaderStyle Font-Bold="True" BackColor="LightPink"></HeaderStyle>
   </cc1:myCustDG>

4. Set control properties in your codebihind page

<font size="2">//
MyCustDG1.strConn = "data source=.;initial catalog=Northwind;" + 
                    "persist security info=False;user id=sa;password=";
MyCustDG1.sqlQuery = "select CustomerID,CompanyName," + 
                     "ContactName,City,Country from customers";
MyCustDG1.Visible = true;
MyCustDG1.autoCols = true;
MyCustDG1.AlphabaticPaging = true;
MyCustDG1.PagingColumn = "CompanyName";
MyCustDG1.GetDataGrid();
//
</font>

Control's properties

1. strConn: SQL connection string
2. sqlQuery: Select query for fill DataGrid
3. AlphabaticPaging (bool): true - show alphabatic paging, false - show normal paging
4. PagingColumn: Column name which depends on alphabatic paging 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
Around five years of experience in the field of application software development including
Three years of experience in .NET technology.

Comments and Discussions

 
Generalthanks man [modified] Pin
thenam25-Sep-07 10:54
thenam25-Sep-07 10:54 
Generalit's sound exciting Pin
thenam25-Sep-07 0:12
thenam25-Sep-07 0:12 
I'll make an example.Laugh | :laugh:

Live for LOVE

Questionquestion? Pin
gmageshh27-Oct-06 10:11
gmageshh27-Oct-06 10:11 
AnswerHow do i use Stored Procedure instead of sql query? Urgent!!!! Pin
GM7-Aug-09 10:07
GM7-Aug-09 10:07 
GeneralUseless without Source Code Pin
pbansal8-Aug-06 2:15
pbansal8-Aug-06 2:15 
Questionwhere is the source? Pin
Skunkyb5-Mar-06 22:33
Skunkyb5-Mar-06 22:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.