This is a migrated thread and some comments may be shown as answers.

[Solved] Problem with ComboBox inside RadGrid ItemTemplate

1 Answer 144 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Condorito
Top achievements
Rank 1
Condorito asked on 18 May 2009, 03:14 PM
Hi, I have a ComboBox inside a RadGrid ItemTemplate with EnableLoadOnDemand set to true, and I can't retrieve the selected value on postback:

<telerik:GridTemplateColumn HeaderText="New Status" UniqueName="Status" AllowFiltering="False">  
                        <ItemTemplate>  
                                 <telerik:RadComboBox runat="Server" ID="rcbNewStatus"  
                                        Width="300px"  
                                        MarkFirstMatch = "True"  
                                        DataSourceID ="sqlStatusList"  
                                        EnableLoadOnDemand = "True"  
                                        HighlightTemplatedItems = "True"  
                                        OnClientItemsRequested="UpdateItemCountField"  
                                        OnItemDataBound="rcbStatus_ItemDataBound"  
                                        OnDataBound = "rcbStatus_DataBound"  
                                        OnItemsRequested="rcbStatus_ItemsRequested"  
                                      EnableViewState ="True"  
                                        >  
                                        <HeaderTemplate>  
                                            <ul>  
                                                 <li class="col1">Status Code</li>  
                                                 <li class="col2">Status Description</li>  
                                            </ul>  
                                         </HeaderTemplate>  
                                         <ItemTemplate>  
                                            <ul>  
                                                <li class="col1"><%# DataBinder.Eval(Container.DataItem, "StatusCode") %></li>  
                                                <li class="col2"><%# DataBinder.Eval(Container.DataItem, "StatusDesc") %></li>  
                                            </ul>          
                                         </ItemTemplate>  
                                         <FooterTemplate>  
                                            A Total of <asp:Literal runat="server" ID="rcbItemsCount" /> items              
                                         </FooterTemplate>  
</telerik:RadComboBox>  

Everything works perfectly, each comboBox in the Grid loads the right data, etc.  The only problem is that if I try to access the selected value server-side, I get an empty string.  This is how I'm trying to access the value, I iterate through the GridItems of the RadGrid, and I can see the ComboBox object and its properties, but the content don't seem to persist and neither does the selected value:

If TypeOf (oControl) Is RadComboBox Then  
       sStatus = CType(oControl, RadComboBox).SelectedValue  
End If  

Am I missing something?

Thank you.



1 Answer, 1 is accepted

Sort by
0
Condorito
Top achievements
Rank 1
answered on 18 May 2009, 04:33 PM
Never mind, I wasn't able to get the values because I was recreating the grid both on callback and on postback.  I was only checking for one, but not the other, this solved the issue:

If Page.IsCallback = False And Page.IsPostBack = False Then 
            GetGridData() 
 End If 



Tags
ComboBox
Asked by
Condorito
Top achievements
Rank 1
Answers by
Condorito
Top achievements
Rank 1
Share this question
or