MultiHeader Code Snipset enjoy:)

Discussion in 'ASP .Net Datagrid Control' started by Etariq, Jul 15, 2006.

  1. Etariq

    Etariq Guest

    protected void GridViewData_RowDataBound(object sender, GridViewRowEventArgs
    e)

    {

    // 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,
    DataControlRowState.Normal);

    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;

    row.Cells.Add(Cell);

    }

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

    }

    }
    Etariq, Jul 15, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. www.douglassdavis.com

    Do you enjoy programming using J2EE Web?

    www.douglassdavis.com, Aug 10, 2005, in forum: Java
    Replies:
    6
    Views:
    344
    Stephan Eggermont
    Aug 16, 2005
  2. Heinrich D. Debunked

    Python enjoy our products

    Heinrich D. Debunked, May 22, 2004, in forum: Python
    Replies:
    0
    Views:
    286
    Heinrich D. Debunked
    May 22, 2004
  3. consultant
    Replies:
    1
    Views:
    376
    Consultant
    May 18, 2007
  4. Replies:
    0
    Views:
    516
  5. ur-opener

    ENJOY

    ur-opener, Aug 1, 2008, in forum: Python
    Replies:
    0
    Views:
    339
    ur-opener
    Aug 1, 2008
Loading...

Share This Page