Datagrid ... is this the control from hell?

B

Bill

I am trying to programatically alter the style of x column headings on a
datagrid. can someone point me in the direction of anything that could help
me determine how this is done?

I have:
- retreived my data
- processed my data
- displayed my data

My desired result would be something along the lines of:

.... <td>Heading 1</td><td class=NewStyle>Heading 2</td>...

I will know what headings I need to alter at the data processing (business)
layer. I will send the information to the web page along with the data to be
displayed. What I can't determine how to do is programatically target a
specific column name.

Any assistance will help keep my sanity.
 
B

Bill

I found a solution.

When the data source is bounded to the datagrid control I can use the
ItemDataBound event to then interrogate what item type is being bounded.
i.e.:

Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
DataGrid1.ItemDataBound
If e.Item.ItemType = ListItemType.Header Then

End If
End Sub

I can then:

e.Item.Cells(0).CssClass = "NewClassName"

Because I know what column names I want to adjust (in the bl layer at run
time) I can pass that dynamic information back and rip through it (replacing
the e.Item.Cells(Integer) with the particular cell number).

Cheers
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,143
Messages
2,570,822
Members
47,368
Latest member
michaelsmithh

Latest Threads

Top