Hello,
I have several RadComboBoxes that interact with each other using client-side methods and requesting the items on demand, like here: http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx
This works well, but when I need the SelectedValue it's always empty.
Can anyone help me please? (I don't know what I'm doing wrong...)
Here I put the code used:
RadComboBoxes
Scripts
Page_Load (server-side)
Rest of functions
When I try to get cboLocalidadT.SelectedValue in function LoadNombresVia
Thank you very much for your help!!
I have several RadComboBoxes that interact with each other using client-side methods and requesting the items on demand, like here: http://demos.telerik.com/aspnet-ajax/combobox/examples/functionality/multiplecomboboxes/defaultcs.aspx
This works well, but when I need the SelectedValue it's always empty.
Can anyone help me please? (I don't know what I'm doing wrong...)
Here I put the code used:
RadComboBoxes
<telerik:RadComboBox ID="cboProvinciaT" runat="server" Width="200px" OnClientSelectedIndexChanging="LoadLocalidades" OnItemsRequested="cboProvinciaT_ItemsRequested" MarkFirstMatch="true" Skin="Sunset"></telerik:RadComboBox><telerik:RadComboBox ID="cboLocalidadT" runat="server" Width="200px" OnClientSelectedIndexChanging="LoadTiposVia" OnClientItemsRequested="ItemsLoaded" OnItemsRequested="cboLocalidadT_ItemsRequested" MarkFirstMatch="true" Skin="Sunset"></telerik:RadComboBox><telerik:RadComboBox ID="cboTipoViaT" runat="server" Width="80px" OnClientSelectedIndexChanged="LoadNombresVia" OnClientItemsRequested="ItemsLoaded" OnItemsRequested="cboTipoViaT_ItemsRequested" MarkFirstMatch="true" Skin="Sunset"></telerik:RadComboBox><telerik:RadComboBox ID="cboNombreVia" runat="server" OnClientItemsRequested="ItemsLoaded" OnItemsRequested="cboNombreVia_ItemsRequested" Filter="Contains" Skin="Sunset"></telerik:RadComboBox>Scripts
<script type="text/javascript"> var LocalidadesCombo; var TiposViaCombo; var NombresVia; function pageLoad() { LocalidadesCombo = $find("<%= cboLocalidadT.ClientID %>"); TiposViaCombo = $find("<%= cboTipoViaT.ClientID %>"); NombresVia = $find("<%= cboNombreVia.ClientID %>"); } function LoadLocalidades(sender, eventArgs) { var item = eventArgs.get_item(); LocalidadesCombo.set_text("Cargando..."); TiposViaCombo.clearSelection(); if (item.get_index() > 0) { LocalidadesCombo.requestItems(item.get_value(), false); LocalidadesCombo.clearSelection(); } else { LocalidadesCombo.set_text(" "); LocalidadesCombo.clearItems(); TiposViaCombo.set_text(" "); TiposViaCombo.clearItems(); } } function LoadTiposVia(sender, eventArgs) { var item = eventArgs.get_item(); TiposViaCombo.set_text("Cargando..."); TiposViaCombo.requestItems(item.get_value(), false); TiposViaCombo.clearSelection(); if (item.get_index() > 0) { TiposViaCombo.requestItems(item.get_value(), false); TiposViaCombo.clearSelection(); } else { TiposViaCombo.set_text(" "); TiposViaCombo.clearItems(); NombresVia.set_text(" "); NombresVia.clearItems(); } } function LoadNombresVia(sender, eventArgs) { var item = eventArgs.get_item(); NombresVia.set_text("Cargando..."); NombresVia.requestItems(item.get_value(), false); NombresVia.clearSelection(); } function ItemsLoaded(sender, eventArgs) { sender.showDropDown(); }</script>Page_Load (server-side)
if (!Page.IsPostBack){ CargarProvincias(); //This method fill cboProvinciaT}else if (!Page.IsCallback){ LoadLocalidades(cboProvinciaT.SelectedValue); LoadTiposVia(cboLocalidadT.SelectedValue); LoadNombresVia(cboTipoViaT.SelectedValue);}Rest of functions
#region Direcciónprotected void LoadLocalidades(string pIdProvincia){ try { AD.Motor mMotorAD = new AD.Motor(); DataTable mDT = new DataTable(); mDT = mMotorAD.ExecuteDataTable("Select 0 as ID, 'Localidad...' as Nombre union SELECT ID, Nombre FROM tlLocalidadDN where idProvincia=" + pIdProvincia + " ORDER BY Nombre ASC"); DataSet mDS = new DataSet(); mDS.Tables.Add(mDT); cboLocalidadT.DataTextField = "Nombre"; cboLocalidadT.DataValueField = "ID"; cboLocalidadT.DataSource = mDS.Tables[0]; cboLocalidadT.DataBind(); } catch (Exception ex) { throw ex; } }protected void LoadTiposVia(string pIdLocalidad){ try { AD.Motor mMotorAD = new AD.Motor(); DataTable mDT = new DataTable(); mDT = mMotorAD.ExecuteDataTable("Select 0 as ID, 'VÃa..' as Nombre union SELECT ID, Nombre FROM tlTipoViaDN ORDER BY Nombre ASC"); DataSet mDS = new DataSet(); mDS.Tables.Add(mDT); cboTipoViaT.DataTextField = "Nombre"; cboTipoViaT.DataValueField = "ID"; cboTipoViaT.DataSource = mDS.Tables[0]; cboTipoViaT.DataBind(); } catch (Exception ex) { throw ex; }}protected void LoadNombresVia(string pIdTipoVia){ try { //HERE ALWAYS GET empty ("")
string mIdLocalidad = cboLocalidadT.SelectedValue;
AD.Motor mMotorAD = new AD.Motor(); DataTable mDT = new DataTable(); mDT = mMotorAD.ExecuteDataTable("Select 0 as ID, ' Nombre de la VÃa..' as Nombre union SELECT ID, Nombre FROM tlViaDN where idLocalidad=" + mIdLocalidad + " and idTipovia=" + pIdTipoVia + " order by Nombre"); DataSet mDS = new DataSet(); mDS.Tables.Add(mDT); cboNombreVia.DataTextField = "Nombre"; cboNombreVia.DataValueField = "ID"; cboNombreVia.DataSource = mDS.Tables[0]; cboNombreVia.DataBind(); } catch (Exception ex) { throw ex; }}protected void LoadNombresVia(string pIdTipoVia, string pIdLocalidad){ try { AD.Motor mMotorAD = new AD.Motor(); DataTable mDT = new DataTable(); mDT = mMotorAD.ExecuteDataTable("Select 0 as ID, ' Nombre de la VÃa..' as Nombre union SELECT ID, Nombre FROM tlViaDN where idLocalidad=" + pIdLocalidad + " and idTipovia=" + pIdTipoVia + " order by Nombre"); DataSet mDS = new DataSet(); mDS.Tables.Add(mDT); cboNombreVia.DataTextField = "Nombre"; cboNombreVia.DataValueField = "ID"; cboNombreVia.DataSource = mDS.Tables[0]; cboNombreVia.DataBind(); } catch (Exception ex) { throw ex; }}protected void cboNombreVia_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e){ LoadNombresVia(e.Text);}protected void cboProvinciaT_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e){ CargarProvincias();}protected void cboLocalidadT_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e){ LoadLocalidades(e.Text);}protected void cboTipoViaT_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e){ LoadTiposVia(e.Text);}#endregionWhen I try to get cboLocalidadT.SelectedValue in function LoadNombresVia
protected void LoadNombresVia(string pIdTipoVia) { try { //******************************************** //**** HERE ALWAYS GET EMPTY VALUE --> "" **** //******************************************** string mIdLocalidad = cboLocalidadT.Text; //******************************************** AD.Motor mMotorAD = new AD.Motor(); DataTable mDT = new DataTable(); mDT = mMotorAD.ExecuteDataTable("Select 0 as ID, ' Nombre de la VÃa..' as Nombre union SELECT ID, Nombre FROM tlViaDN where idLocalidad=" + mIdLocalidad + " and idTipovia=" + pIdTipoVia + " order by Nombre"); DataSet mDS = new DataSet(); mDS.Tables.Add(mDT); cboNombreVia.DataTextField = "Nombre"; cboNombreVia.DataValueField = "ID"; cboNombreVia.DataSource = mDS.Tables[0]; cboNombreVia.DataBind(); } catch (Exception ex) { throw ex; } }Thank you very much for your help!!