Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > MultiHeader Code Snipset enjoy:)

Thread Tools

MultiHeader Code Snipset enjoy:)

Posts: n/a
protected void GridViewData_RowDataBound(object sender, GridViewRowEventArgs


// the Key in the Sorted List is the index of the cell , the Value is
consist of 3 comma delimited data , the index 0 is for content of the cell
, index 1 is for the

//Column Span and index 2 is for the row span

SortedList creatCels = new SortedList();

creatCels.Add("1", ",5,2");

creatCels.Add("2", "Comments,4,1");

creatCels.Add("3", ",1,2");

SortedList creatCels2 = new SortedList();

creatCels2.Add("1", "Total Amount of,2,1");

creatCels2.Add("2", "Total Amount of,2,1");

GetMyMultiHeader(e, creatCels2);

GetMyMultiHeader(e, creatCels);


public void GetMyMultiHeader(GridViewRowEventArgs e, SortedList GetCels)


if (e.Row.RowType == DataControlRowType.Header)


GridViewRow row;

IDictionaryEnumerator enumCels = GetCels.GetEnumerator();

row = new GridViewRow(0, 0, DataControlRowType.Header,

while (enumCels.MoveNext())


string[] cont = enumCels.Value.ToString().Split(Convert.ToChar("," ));

TableCell Cell;

Cell = new TableCell();

Cell.RowSpan = Convert.ToInt16(cont[2].ToString());

Cell.ColumnSpan = Convert.ToInt16(cont[1].ToString());

Cell.Controls.Add(new LiteralControl(cont[0].ToString()));

Cell.HorizontalAlign = HorizontalAlign.Center;

Cell.ForeColor = System.Drawing.Color.White;



e.Row.Parent.Controls.AddAt(0, row);



Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the difference between code inside a <script> tag and code in the code-behind file? keithb ASP .Net 1 03-29-2006 01:00 AM
Fire Code behind code AND Javascript code associated to a Button Click Event =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?= ASP .Net 4 02-11-2004 07:31 AM
Re: Code Behind vs. no code behind: error Ben Miller [msft] ASP .Net 1 06-28-2003 01:46 AM
Re: C# Equivalent of VB.Net Code -- One line of code, simple Ian ASP .Net 0 06-25-2003 01:14 PM
Re: C# Equivalent of VB.Net Code -- One line of code, simple Ron ASP .Net 1 06-24-2003 07:18 PM