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

Grid Edit Usercontrol RadComboBox SelectedIndexChanged not firing

3 Answers 133 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Steve Todd
Top achievements
Rank 1
Steve Todd asked on 24 Apr 2009, 07:55 AM
Hi Guys

To improve performance and allow a more flexibility I have developed a simple user control to handle the editing of a rad grid row. On the usercontrol there are 2 RadComboBoxes (Job and Task) which both have the AutoPostBack property set to True. The idea is when you select a Job the Task combo box only populates Tasks relevant to that Job. 

I have a major problem in that after selecting a Job from the dropdownlist (populated correctly via the ItemsRequested method) the Job_SelectedIndexChanged event isn't fired, however the Task_ItemsRequested is fired but I cannot populate this correctly because I cannot get access to the value of the selected item in the Job dropdownbox. In the debugger I've tried a number of ways to get the SelectedValue e.g. FindControl("Job").SelectedValue, Ctype(.. RadComboBox..) but I only get back a blank string.

When this functionality was part of the RadGrid it seemed to work fine, however now I've moved it into a UserControl it's seems to be faultering.

Any Ideas

Steve   

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 24 Apr 2009, 10:14 AM
Hello Steve,

I tried out the same senario at my end and it worked as expected. Below given is the code i tried, check out for differences with your code:
ascx:
<telerik:RadComboBox ID="RadComboBox1" DataSourceID="SqlDataSource1" DataValueField="Job" AutoPostBack="true" DataTextField="Job" runat="server" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"
</telerik:RadComboBox> 
 
<telerik:RadComboBox ID="RadComboBox2" runat="server"
</telerik:RadComboBox> 
 

ascx.cs:
protected void RadComboBox1_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e) 
    { 
        RadComboBox combobox1 = (RadComboBox)o; 
        string strtxt = combobox1.SelectedItem.Text; 
        string value = combobox1.SelectedValue.ToString(); 
        if(value == "Engineer"
        { 
            RadComboBox2.DataSourceID = "SqlDataSource1"
            RadComboBox2.DataTextField = "Task1"
        } 
        else if(value == "Teacher"
        { 
            RadComboBox2.DataSourceID = "SqlDataSource1"
            RadComboBox2.DataTextField = "Task2"
        } 
    } 

Thanks

Princy.

0
Steve Todd
Top achievements
Rank 1
answered on 24 Apr 2009, 10:30 AM
Hi Princy

Thanks for the reply. The code looks the same. Some further info - the grid on the page calling the usercontrol is Ajaxified if that makes a difference, also I have noticed that the SelectedIndexChanged does fire but only after clicking the Cancel button on my UserControl (see below). 

RadComboBox definition
<telerik:RadComboBox runat="server" CausesValidation="true"  
                        Height="140px"
                        HighlightTemplatedItems="true"
                        EnableLoadOnDemand="True"
                        DataTextField="Description" 
                        DataValueField="No" 
                        ID="rcboJobNo"
                        AutoPostBack="true" 
                        Width="450px"
                        OnSelectedIndexChanged="rcboJobNo_SelectedIndexChanged"
                        >
VB Code Behind
 Protected Sub rcboJobNo_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)
        Dim rcboTask As RadComboBox = CType(FindControl("rcboTaskNo"), RadComboBox)

Cancel Button    
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" SkinID="BtnSmlCancel" CausesValidation="False"/>

Steve
0
Steve Todd
Top achievements
Rank 1
answered on 27 Apr 2009, 10:17 AM
Through a lot of debugging, I've managed to solve my problem - though I'm not too sure how. I wasdynamically adding in radinput manager target controls on ItemCreated. When I commented these lines of code out the drop downs worked fine. Something odd going on but it's solved now.

Steve
Tags
Grid
Asked by
Steve Todd
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Steve Todd
Top achievements
Rank 1
Share this question
or