开发者

How to assign ID to TR generated by datalist/datagrid in asp.net?

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");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜