Hi,
I have a RadGrid with a custom CommandItemTemplate. In my CommandItemTemplate I have a RadComboBox with the 'Autopostback' property enabled. I would like to change the grid's data according the RadComboBox selected value. But after the RadGrid rebind, the RadComboBox doesn't keep the 'SelectedValue' property.
If I don't call the RadGrid Rebind method it works fine! But the grid doesn't change so I have to rebind the grid.
What I need to do to keep the RadComboBox SelectedValue after a RadGrid rebind?
Here is a simple sample:
ascx:
Code behind:
I have a RadGrid with a custom CommandItemTemplate. In my CommandItemTemplate I have a RadComboBox with the 'Autopostback' property enabled. I would like to change the grid's data according the RadComboBox selected value. But after the RadGrid rebind, the RadComboBox doesn't keep the 'SelectedValue' property.
If I don't call the RadGrid Rebind method it works fine! But the grid doesn't change so I have to rebind the grid.
What I need to do to keep the RadComboBox SelectedValue after a RadGrid rebind?
Here is a simple sample:
ascx:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" GridLines="None" DataSourceID="XmlDataSource1"> <MasterTableView CommandItemDisplay="Top" EditMode="InPlace" DataSourceID="XmlDataSource1"> <RowIndicatorColumn> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <Columns> <telerik:GridEditCommandColumn> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn DataField="CustomerId" HeaderText="CustomerId" SortExpression="CustomerId" UniqueName="CustomerId"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" UniqueName="FirstName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="LastName" HeaderText="LastName" SortExpression="LastName" UniqueName="LastName"> </telerik:GridBoundColumn> </Columns> <CommandItemTemplate> <asp:Label ID="Label1" runat="server" Text="Auto PostBack RadComboBox"></asp:Label> <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="True" onselectedindexchanged="RadComboBox1_SelectedIndexChanged"> <Items> <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" Value="RadComboBoxItem1" /> <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2" Value="RadComboBoxItem2" /> <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem3" Value="RadComboBoxItem3" /> <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem4" Value="RadComboBoxItem4" /> <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem5" Value="RadComboBoxItem5" /> </Items> </telerik:RadComboBox> </CommandItemTemplate> </MasterTableView> </telerik:RadGrid>Code behind:
protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) { this.RadGrid1.Rebind(); }