Reputation: 14285
How can I set ID to TabelRows
generated by DataGrid/DataList
?
I want to assign a row id by myself to every row of DataList
.
Upvotes: 1
Views: 1773
Reputation: 38346
Attach a handler for the ItemDataBound
event on your control:
<asp:DataGrid OnItemDataBound="myGrid_ItemDataBound" ...>
Declare the handler method like this:
protected void myGrid_ItemDataBound(object sender, DataGridItemEventArgs e)
{
e.Item.Attributes.Add("id", "some_id");
}
Upvotes: 3