This control will build a DataList control which is Dynamic and you can give Custome properties to it, Like you can select header CSS style, columns width, on which column you want to put sorting functionality and as per properties set you will find that a nice datalist will be displayed with hover effect on each rows, plus sorting functionality on desired columns.
To make it work you just have to give a DataTable for data to be displayed and you have to set some Properties of DataList.
To use this control as per your requirement set these properties...
1. Columns -- you can opetionaly tell how many columns wil be there in your datatable.
2. sortingColumns -- on which columns you need sorting functionality
3. sortingState -- initially which state will be there for sorting for column like ASC or DSEC
4. columnWidths -- you can specify width of each columns..
5. sortingUpImage -- you can give image for sorting as DESC order..
6. sortingDownImage -- you can give image for sorting as ASC order..
7. tableBorder -- you can give border width of your datalist
8. cellAlign -- Alignment of cells..
9. headerCSSClass -- CSS for Header of DataList..
10. ItemRowStyle -- CSS for Item Template...
11. AlterItemRowStyle -- CSS for AlterItem Template...
12. AddSerialNo -- set true if you want serial number as first column...
13. PageSize -- set rows number that will be displayed as page count rows...
Using the code
To use this code just add reference of this DLL file attached with this article.
In your code you have to just set some properties of this control, like given in this sample code, and you have to give DataTable which is containing your data to be displayed in datalist.
first add this lines into web.config...
<add namespace="MyDataList" assembly="MyDataListControl"
<myDL:myControl1 runat="server" />
dtContact = dSet.Tables["Contact"];
if (dtContact != null)
datalistTest.Columns = dtContact.Columns.Count;
datalistTest.dataTable = dtContact;
datalistTest.tableBorder = 1;
datalistTest.cellAlign = "left";
bool sortColumns = new bool[dtContact.Columns.Count];
int sortState = new int[dtContact.Columns.Count];
int columnwidths = new int[dtContact.Columns.Count];
for (int i = 0; i < dtContact.Columns.Count; i++)
sortColumns[i] = true;
if (i == 0)
columnwidths[i] = 60;
columnwidths[i] = 100;
sortState[i] = 1;
sortState[i] = 2;
datalistTest.sortingColumns = sortColumns;
datalistTest.sortingState = sortState;
datalistTest.columnWidths = columnwidths;
datalistTest.AlterItemRowStyle = "Alternate";
datalistTest.headerCSSClass = "GridHeader";
If you can not understand how to use this then ask me i will explain you, this control is still in under construnction for better functionality.
Assembly version 220.127.116.11
Chirag Patel, a Programmer Analyst in a well known IT company working on .NET Technologies since last 2 years. He is interested in Pure business logic and fuzzy logic. his area of interest is in C#.NET, VB.NET and MSSQL 2005.
catch me on: http://groups.google.com/group/codewar