swapping columns on ItemDataBoundEventHandler

Discussion in 'ASP .Net Datagrid Control' started by Tim, Apr 21, 2004.

  1. Tim

    Tim Guest

    Hi,

    In the below code, a count of the DataGrid1.Columns yields zero
    columns even after the ItemDataBound event is raised; otherwise,
    DataGrid1.DataBind() works fine if I comment out
    ItemDataBoundEventHandler as a datagrid with 8 columns and 20 rows is
    rendered. In the GetTable(OleDBDataReader) function, I take a dataset
    and append a column that displays the row- count at the very front of
    the datagrid. I want to swap this row-count column with the first
    column of the dataset.

    ....
    DataSet ds = new DataSet();
    ds.Tables.Add(this.GetTable(dr));
    DataGrid1.DataSource = ds.Tables[0];

    DataGrid1.DataBind();

    }

    void ItemDataBoundEventHandler(object sender, DataGridItemEventArgs e)
    {
    DataGridColumn dgCol1;
    DataGridColumn dgCol2;

    dgCol1 = DataGrid1.Columns[0];
    dgCol2 = DataGrid1.Columns[1];
    DataGrid1.Columns.AddAt(0,dgCol2);
    DataGrid1.Columns.AddAt(1,dgCol1);
    }
     
    Tim, Apr 21, 2004
    #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. =?Utf-8?B?TXJNaWtl?=

    ItemDataBoundEventHandler

    =?Utf-8?B?TXJNaWtl?=, Nov 29, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    920
    =?Utf-8?B?TXJNaWtl?=
    Dec 1, 2004
  2. shrikanthraon

    Swapping of columns and rows in gridview

    shrikanthraon, Aug 9, 2009, in forum: .NET
    Replies:
    0
    Views:
    1,579
    shrikanthraon
    Aug 9, 2009
  3. Tim

    Swapping columns in a DataGrid

    Tim, Apr 16, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    200
    Scott Mitchell [MVP]
    Apr 16, 2004
  4. Replies:
    1
    Views:
    112
  5. VA

    Swapping table columns

    VA, Nov 1, 2005, in forum: Javascript
    Replies:
    10
    Views:
    213
Loading...

Share This Page