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

Access Row properties for a Grid Combobox

1 Answer 158 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Navneet
Top achievements
Rank 1
Navneet asked on 22 Jun 2011, 10:14 PM
Hi,

I have a RadCombo inside a RadGrid. I am using RadCombo inside a templated column so that user can select any value without changing the Grid mode to Edit. My Goal is to update the server information asyncronously when the user changes the grid value.

I have the onCLientSelectedIndexChange event functional. But I need the Primary Key from the Row.

Any suggestions on How i can achieve this behavior?
Thanks,
Navneet


1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 23 Jun 2011, 05:09 AM
Hello Navneet,

In order to get the primary key value, attach the event OnClientSelectedIndexChanged from server side and pass the index. Try the following code snippet to get the DataKeyValue. Hope this helps.

C#:
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
        if (e.Item is GridDataItem)
        {
            GridDataItem dataItem = (GridDataItem)e.Item;
            RadComboBox combo = (RadComboBox)dataItem.FindControl("Radcombo");
            int index = e.Item.ItemIndex;
            combo.OnClientSelectedIndexChanged = "function (sender,args){rowIndex('" + index + "');}";              
        }
}

Javascript:
function rowIndex(index)
{
   var row = $find('<%= RadGrid1.ClientID %>').get_masterTableView().get_dataItems()[index];
   alert(row.getDataKeyValue("EmployeeID"));//DataKeyName
}


Note: Set ClientDataKeyNames as EmployeeID.

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