This is a migrated thread and some comments may be shown as answers.

[Solved] Display Row ID

1 Answer 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Todd
Top achievements
Rank 1
Todd asked on 30 Jun 2008, 05:44 PM
OK, I'm sure there is a really simple answer to this but I couldn't find anything in the docs. I want to display the row id in my grid as the first column. How do I do this?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Jul 2008, 05:39 AM
Hi Todd,

Set the ID field as the DataKeyName and try setting the text of the GridBoundColumn as shown below.

ASPX:
<MasterTableView DataKeyNames="ID" > 

CS:
 protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string strID = item.GetDataKeyValue("ID").ToString(); 
            item["columnUniqueName"].Text = strID
        } 
   } 


Thanks
Shinu
Tags
Grid
Asked by
Todd
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or