I am C# noobie, I have inherited big C# project and I have to do a litlle modifications.
First let me past the code:
protected void Page_Load(object sender, EventArgs e)
{
// Loading rcb1
this.dsX.SelectParameters["parameter1"].DefaultValue = XXX.XXX.ToString();
this.dsX.SelectParameters["parameter2"].DefaultValue = this.XXX.ToString();
if ( !IsPostBack )
{
Control c = sender as Control;
RadComboBox rcb1 = c.Parent.FindControl("rcb1") as RadComboBox;
// Loading rcb2
this.dsY.SelectParameters["parameter1"].DefaultValue = XXX.XXX.ToString();
this.dsY.SelectParameters["parameter1"].DefaultValue = this.XXX.ToString();
// Value of first option from rcb1
this.dsY.SelectParameters["rcb1_value"].DefaultValue = rcb1.SelectedValue.ToString();
}
}
protected void rcb1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
{
if (e.Value != "")
{
Control c = o as Control;
RadComboBox rcb1 = c.Parent.FindControl("rcb1") as RadComboBox;
RadComboBox rcb2 = c.Parent.FindControl("rcb2") as RadComboBox;
this.dsUsers.SelectParameters["parameter1"].DefaultValue = XXX.XXX.ToString();
this.dsUsers.SelectParameters["parameter2"].DefaultValue = this.XXX.ToString();
this.dsUsers.SelectParameters["parameter3"].DefaultValue = e.Value.ToString();
}
}
<tr>
<td align="left" height="22px">
LABEL
</td>
<td align="left" height="22px">
<telerik:RadComboBox ID="rcb1" runat="server" DataSourceID="dsX" DataTextField="PONotificationName"
DataValueField="ID" Skin="Vista" meta:resourcekey="xxResource1"
OnSelectedIndexChanged="rcb1_SelectedIndexChanged" AutoPostBack="true">
</telerik:RadComboBox>
<asp:SqlDataSource ID="dsX" runat="server" ConnectionString="<%$ connectionStrings:XXX %>"
SelectCommand="XXX" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter Name="parameter1" Type="Int32" />
<asp:Parameter Name="parameter2" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td align="left" height="22px">
LABEL 2
</td>
<td align="left" height="22px">
<telerik:RadComboBox ID="rcb2" runat="server" DataSourceID="dsY" DataTextField="Name"
DataValueField="ID" Skin="Vista" meta:resourcekey="xxResource2">
</telerik:RadComboBox>
<asp:SqlDataSource ID="dsY" runat="server" ConnectionString="<%$ connectionStrings:XXX %>"
SelectCommand="XXX2" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter Name="parameter1" Type="Int32" />
<asp:Parameter Name="parameter2" Type="Int32" />
<asp:Parameter Name="parameter3" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
</td>
</tr>
My problem is those comboBoxes. The code is working fine, but the problem is before user do any action the second comboBox (rcb2) stays blank.
I have to load second combobox(rcb2) with the data from first combobox(rcb1) using stored procedure.
I have tried .SelectedValue. Item[index].value and others it returns null.
Maybe the problem is that first ComboBox doesnt have definition for selected item?
Can anybody help me solve this?
I can either add new blank item to rcb1 at the top. But I had problems with that too.
Solved my problem with emptymessage... gosh took me whole day!