I am creating a RadGrid programmatically. It has 2 template columns as well.
When we click Edit button for a row then, one template column has to be changed to a dropdown and other column should be changed to RadListbox of checkboxes.
Also, the ItemTemplate value should be used to select the appropriate checkboxes ni the RadListBox.
I have written the code to select the ListBoxItems of RadListBox, but it doesn't work. Can some help.
The code I have written is of this way:-
In RadGrid's Item Data Bound event:-
When we click Edit button for a row then, one template column has to be changed to a dropdown and other column should be changed to RadListbox of checkboxes.
Also, the ItemTemplate value should be used to select the appropriate checkboxes ni the RadListBox.
I have written the code to select the ListBoxItems of RadListBox, but it doesn't work. Can some help.
The code I have written is of this way:-
In RadGrid's Item Data Bound event:-
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridDataItem gridDataItem = e.Item
as
GridDataItem;
DataRowView dvRow = gridDataItem.DataItem
as
DataRowView;
RadComboBox cmbPositionID = gridDataItem.FindControl(
"comboPositionID"
)
as
RadComboBox;
cmbPositionID.SelectedValue = dvRow[
"PositionID"
].ToString();
RadListBox listBox = gridDataItem.FindControl(
"comboLanguageID"
)
as
RadListBox;
string
value = dvRow[
"LanguageID"
].ToString();
string
[] values = value.Split(
new
char
[] {
','
}, StringSplitOptions.RemoveEmptyEntries);
foreach
(
string
val
in
values)
{
RadListBoxItem item = listBox.FindItemByText(val);
if
(item !=
null
)
item.Selected =
true
;
}
}