Adding RadComboBox to RadGrid Edit

Kush picture Kush · Aug 13, 2009 · Viewed 12.6k times · Source

I have added a RadControl, RadGrid and I need to add a radComboBox in the edit mode.

When user clicks on the radComboBox, I need to get both "text" and "value" of the radComboBox to save to table when user updates values.

<telerik:RadComboBox ID="RadComboBox1" Runat="server" 
             DataSourceID="SqlDataSource1" DataTextField="docCategoryName" 
             DataValueField="docCategoryID" Height="200px" Skin="Vista">

When user selects from the radComboBox, I need to get the value of DataTextField & DataValueField into a HiddenField.

Answer

Program.X picture Program.X · Aug 13, 2009

Telerik are the best people to help you with this, but from their site (and from memory):

http://www.telerik.com/help/aspnet-ajax/combo_clientsideonclientselectedindexchanged.html

If you have your radCombo:

<telerik:RadComboBox
 ID="RadComboBox1"
 runat="server"
 OnClientSelectedIndexChanged="OnClientSelectedIndexChanged">
</telerik:RadComboBox> 

With your JS event:

<script language="javascript" type="text/javascript">
function OnClientSelectedIndexChanged(sender, eventArgs)
{
 var item = eventArgs.get_item();

// get the text and value elements
var text=item.get_text();
var val=item.get_value();

$('#hiddenField').val(val);
}
</script>

Where hiddenField is the ID of the hidden field.