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

datakey problem

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
jaws1021
Top achievements
Rank 1
jaws1021 asked on 27 Jun 2010, 07:26 PM
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) // similar to RowDataBound event in GridView  
    {
        if (e.Item is GridDataItem)// gets the row collection  
        {
            GridDataItem item = (GridDataItem)e.Item;
            rgManager.SelectParameters["proID"].DefaultValue = ????

        }
    }  

what would replace this ???? part.. I am trying to get the datakeyvalue of proID ..I have tried this but it is complaining...
rgManager.MasterTableView.DataKeyValues[e.Item.ItemIndex];
Actually ItemDataBound is not even executing creating grid...Please help..

1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 28 Jun 2010, 08:39 AM
Hello,

You can try any of the following method to access DataKeyValue.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            string id = item.GetDataKeyValue("proID").ToString(); 
                             //   or 
            string proId= RadGrid1.MasterTableView.DataKeyValues[item.ItemIndex]["proID"].ToString(); 
        } 
   } 

Also check whether you have attached 'OnItemDataBound' event to RadGrid.

Thanks,
Princy.
Tags
Grid
Asked by
jaws1021
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or