3 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 02 Nov 2011, 04:59 AM
Hello Tina,
Try the following code snippet in SelectedIndexChanged event of RadComboBox.
C#:
Thanks,
Shinu.
Try the following code snippet in SelectedIndexChanged event of RadComboBox.
C#:
protected
void
combo_SelectedIndexChanged(
object
sender, RadComboBoxSelectedIndexChangedEventArgs e)
{
RadComboBox combo = (RadComboBox)sender;
GridDataItem item = (GridDataItem)combo.NamingContainer;
string
id = Convert.ToInt32(item.GetDataKeyValue(
"ID"
)).ToString();
}
Thanks,
Shinu.
0
Tina
Top achievements
Rank 1
answered on 02 Nov 2011, 05:22 PM
Thanks Shinu.
But i want to access hte row in which combobox is present and then access the datakeyvalue.how can it be done?
But i want to access hte row in which combobox is present and then access the datakeyvalue.how can it be done?
0
Shinu
Top achievements
Rank 2
answered on 03 Nov 2011, 07:27 AM
Hello Tina,
In order to get the datakeyvalue, attach the event OnClientSelectedIndexChanged from server side and pass the index.
C#:
Javascript:
Thanks,
Shinu.
In order to get the datakeyvalue, attach the event OnClientSelectedIndexChanged from server side and pass the index.
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(
"ID"
));
//DataKeyName
}
Thanks,
Shinu.