Hello,
I have a bit of an issue:
I have four ComboBoxes on the page as seen below:
all data-bound from c# like so (including selected index changed);
and the existing records are bound like so:
what is currently occurring is the first ComboBox is being bound with the record but the other 3 are blank where they should display the records from the db.
What needs to happen is when the user clicks 'Edit' button the user control becomes visible with ComboBoxes displaying the existing(non-edited data) and allow the user to change the ComboBox selected value.
I have a bit of an issue:
I have four ComboBoxes on the page as seen below:
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server"> <AjaxSettings> <telerik:AjaxSetting AjaxControlID="ddlCountry"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="ddlState" UpdatePanelHeight="" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="ddlState"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="ddlLocation" UpdatePanelHeight="" /> </UpdatedControls> </telerik:AjaxSetting> <telerik:AjaxSetting AjaxControlID="ddlLocation"> <UpdatedControls> <telerik:AjaxUpdatedControl ControlID="ddlPostcode" UpdatePanelHeight="" /> </UpdatedControls> </telerik:AjaxSetting> </AjaxSettings></telerik:RadAjaxManagerProxy> <table id="Table1" width="100%" class="style1"> <tr runat="server" width="150px" id="tr10"> <td> Country </td> <td> <telerik:RadComboBox ID="ddlCountry" runat="server" OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged" Width="300px" EnableLoadOnDemand="True" AutoPostBack="True"> </telerik:RadComboBox> <asp:RequiredFieldValidator ID="rfvCountry" runat="server" ErrorMessage="*" ControlToValidate="ddlCountry" ValidationGroup="Customer"></asp:RequiredFieldValidator> </td> </tr> <tr runat="server" id="trState"> <td> State </td> <td> <telerik:RadComboBox ID="ddlState" OnSelectedIndexChanged="ddlState_SelectedIndexChanged" Width="300px" runat="server" AutoPostBack="True"> </telerik:RadComboBox> <asp:RequiredFieldValidator ID="rfvState" runat="server" ErrorMessage="*" ControlToValidate="ddlState" ValidationGroup="Customer"></asp:RequiredFieldValidator> </td> <td> Location </td> <td> <telerik:RadComboBox ID="ddlLocation" OnSelectedIndexChanged="ddlLocation_SelectedIndexChanged" Width="300px" runat="server" AutoPostBack="True"> </telerik:RadComboBox> <asp:RequiredFieldValidator ID="rfvLocation" runat="server" ErrorMessage="*" ControlToValidate="ddlLocation" ValidationGroup="Customer"></asp:RequiredFieldValidator> </td> </tr> <tr runat="server" id="trPostcode"> <td> Postcode </td> <td> <telerik:RadComboBox ID="ddlPostcode" runat="server" Width="300px"> </telerik:RadComboBox> <asp:RequiredFieldValidator ID="rfvPostcode" runat="server" ErrorMessage="*" ControlToValidate="ddlPostcode" ValidationGroup="Customer"></asp:RequiredFieldValidator> </td> </tr> </table>all data-bound from c# like so (including selected index changed);
#region Location ddlsprivate void BindCountry(){ string sql = "SELECT DISTINCT LookupID_LookupTable, LookupID, LookupParentID FROM " + XDEV.xd_Schema.ToString() + "xd_lookup_tables WHERE (LookupParentID = 41)"; DataTable dt = data.GetDataTable(sql); if (dt.Rows.Count > 0) { ddlCountry.DataSource = dt; ddlCountry.DataTextField = "LookupID_LookupTable"; ddlCountry.DataValueField = "LookupID"; ddlCountry.DataBind(); //RadAjaxManager1.FocusControl(ddlCountry); }}private void BindState(string country){ string sql = string.Format("SELECT DISTINCT LookupID_LookupTable, LookupID, LookupParentID FROM " + XDEV.xd_Schema.ToString() + "xd_lookup_tables WHERE ( LookupID_ParentLookupID ={0})", country); DataTable dt = data.GetDataTable(sql); if (dt.Rows.Count > 0) { ddlState.DataSource = dt; ddlState.DataTextField = "LookupID_LookupTable"; ddlState.DataValueField = "LookupID"; ddlState.DataBind(); //RadComboBoxItem StateItem = new RadComboBoxItem("- Select a State -", "0"); //Creates new item for RadCombobox //ddlState.Items.Add(StateItem); }}private void BindLocation(string state){ string sql = string.Format("SELECT DISTINCT LookupID_LookupTable, LookupID, LookupParentID FROM " + XDEV.xd_Schema.ToString() + "xd_lookup_tables WHERE ( LookupID_ParentLookupID = {0})", state); DataTable dt = data.GetDataTable(sql); if (dt.Rows.Count > 0) { ddlLocation.DataSource = dt; ddlLocation.DataTextField = "LookupID_LookupTable"; ddlLocation.DataValueField = "LookupID"; ddlLocation.DataBind(); //RadComboBoxItem LocationItem = new RadComboBoxItem("- Select a Location -", "0"); //Creates new item for RadCombobox //ddlLocation.Items.Add(LocationItem); }}private void BindPostcode(string location){ string sql = string.Format("SELECT DISTINCT LookupID_LookupTable, LookupID, LookupParentID FROM " + XDEV.xd_Schema.ToString() + "xd_lookup_tables WHERE ( LookupID_ParentLookupID = {0})", location); DataTable dt = data.GetDataTable(sql); if (dt.Rows.Count > 0) { ddlPostcode.DataSource = dt; ddlPostcode.DataTextField = "LookupID_LookupTable"; ddlPostcode.DataValueField = "LookupID"; ddlPostcode.DataBind(); //RadComboBoxItem PostcodeItem = new RadComboBoxItem("- Select a Postcode -", "0"); //Creates new item for RadCombobox //ddlPostcode.Items.Add(PostcodeItem); }}protected void ddlCountry_SelectedIndexChanged(object sender, EventArgs e){ BindState(ddlCountry.SelectedValue);}protected void ddlState_SelectedIndexChanged(object sender, EventArgs e){ BindLocation(ddlState.SelectedValue);}protected void ddlLocation_SelectedIndexChanged(object sender, EventArgs e){ BindPostcode(ddlLocation.SelectedValue);}#endregionand the existing records are bound like so:
#region cascading ddlsif (!String.IsNullOrEmpty(dt.Rows[0]["LookupID_Country"].ToString())){ if (ddlCountry.Items.Contains(ddlCountry.Items.FindItemByValue(dt.Rows[0]["LookupID_Country"].ToString()))) { ddlCountry.SelectedValue = dt.Rows[0]["LookupID_Country"].ToString(); BindCountry(); }}if (!String.IsNullOrEmpty(dt.Rows[0]["LookupID_State"].ToString())){ if (ddlState.Items.Contains(ddlState.Items.FindItemByValue(dt.Rows[0]["LookupID_State"].ToString()))) { ddlState.SelectedValue = dt.Rows[0]["LookupID_State"].ToString(); BindState(ddlCountry.SelectedValue); } else { }}if (!String.IsNullOrEmpty(dt.Rows[0]["LookupID_Location"].ToString())){ if (ddlLocation.Items.Contains(ddlLocation.Items.FindItemByValue(dt.Rows[0]["LookupID_Location"].ToString()))) { ddlLocation.SelectedValue = dt.Rows[0]["LookupID_Location"].ToString(); BindLocation(ddlState.SelectedValue); }}if (!string.IsNullOrEmpty(dt.Rows[0]["LookupID_Postcode"].ToString())){ if (ddlPostcode.Items.Contains(ddlPostcode.Items.FindItemByValue(dt.Rows[0]["LookupID_Postcode"].ToString()))) { ddlPostcode.SelectedValue = dt.Rows[0]["LookupID_Postcode"].ToString(); BindPostcode(ddlLocation.SelectedValue); }}#endregion);What needs to happen is when the user clicks 'Edit' button the user control becomes visible with ComboBoxes displaying the existing(non-edited data) and allow the user to change the ComboBox selected value.