Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Applying a class on datagrid

Status
Not open for further replies.

pixel69

Technical User
Sep 25, 2002
56
ZA
How do you apply classes on the datagrid (td's) instead of tr's??

thanx
pixel
[bigcheeks]
 
What do you mean by apply classes?

If you are wanting to work with a cell instead of a row, you need to get access to that control of the datagrid.

In the .aspx file:
Code:
<asp:DataGrid …Attributes… OnItemDataBound=”OnItemDataBoundEventHandler”> //This specifies the function to call when populating the grid.
In your .aspx.cs (or .vb) file:
Code:
public void OnItemDataBoundEventHandler(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
 TableCell tableCell = (TableCell) e.Item.Controls[0]; //Controls[0] is the first column in your grid.   
}

You then can work with the tableCell object to manipulate the specific cell.
Code:
tableCell.Text = &quot;First Column&quot;;
Thanks,

Gabe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top