How to put a DIV inside a DataGrid's column header?

  • Thread starter Thread starter sean.gilbertson
  • Start date Start date
S

sean.gilbertson

Hi everyone,

I'm adding columns to a DataTable, so that I can set it as the
DataSource for a DataGrid. How can I go about putting a DIV element
inside one of the column headers? I'm fine with taking another
approach.

Thanks :-)
Sean
 
Handle the "ItemDataBound" event, which is invoked for every row (including
the header) that is added to a datagrid. You will know its the header row by
checking if e.Item.ItemIndex = -1. From there I believe you can just set
e.Item.Cells(0).text = "<div></div>"
 
Handle the "ItemDataBound" event, which is invoked for every row (including
the header) that is added to a datagrid. You will know its the header row by
checking if e.Item.ItemIndex = -1. From there I believe you can just set
e.Item.Cells(0).text = "<div></div>"







- Show quoted text -

Keith,

Thanks for responding :-)

I actually took this approach, after deciding to keep digging instead
of waiting and lamenting (which can happen with me :-):

/*---------------------*/

TableRow row = new TableRow();

TableCell cell = new TableCell();

/* This is the important part ;-) */
Panel div = new Panel();

cell.Controls.Add(div);

row.Cells.Add(cel);

table_in_my_page.Rows.Add(row);

/*---------------------*/

It works perfectly! I'm very happy with it. And now that I'm rolling
along, I'm very pleased with what ASP.NET 2.0 and Atlas can do!!
We'll see where I can go from here :-)

Take care,
Sean
 
Back
Top