Hi Abhishek,
In order to apply the same logic the code needs to be adapted to the case of multiple ComboBoxes on the page.
The easiest way to achieve the same result is to add the hidden field inside the Template and set its ID to that of the ComboBox with the "Value" suffix. Then you can use the Load event of the RadComboBox instead of the global pageLoad function. The event fires for each RCB on the page and the first parameter holds a reference to the respective RCB, so you do not need to use its ID explicitly. Then finding the respective hidden field is a matter of appending "Value" to the ID of the RCB. Below is the modified code:
<
telerik:RadGrid
ID
=
"dViewQuestionnaireNamesGrid"
runat
=
"server"
AutoGenerateColumns
=
"False"
Width
=
"99.5%"
GridLines
=
"none"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"QuestionName"
UniqueName
=
"QuestionName"
ReadOnly
=
"True"
HeaderText
=
"Attributes"
HeaderStyle-CssClass
=
"background_dbf7ff headertext"
HeaderStyle-ForeColor
=
"#00759B"
HeaderStyle-Font-Bold
=
"true"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"Scoring Logic Type"
HeaderStyle-CssClass
=
"background_dbf7ff headertext"
HeaderStyle-ForeColor
=
"#00759B"
HeaderStyle-Font-Bold
=
"true"
>
<
ItemTemplate
>
<
telerik:RadComboBox
CssClass
=
"singlelineLBox"
ID
=
"drpDownScoringLogicTypes"
runat
=
"server"
OnClientLoad
=
"onLoad"
OnClientSelectedIndexChanged
=
"onSelectedIndexChanged"
>
</
telerik:RadComboBox
>
<
asp:HiddenField
ID
=
"drpDownScoringLogicTypesValue"
runat
=
"server"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
script
type
=
"text/javascript"
>
function onLoad(sender) {
var savedValue = $get(sender.get_id() + "Value").value;
if (savedValue != "" && sender.findItemByValue(savedValue))
sender.findItemByValue(savedValue).select();
}
function onSelectedIndexChanged(sender, eventArgs) {
$get(sender.get_id() + "Value").value = eventArgs.get_item().get_value();
}
</
script
>
I hope this helps.
Best wishes,
Simon
the Telerik team