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
.
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");
}
精彩评论