RadCombo SelectedValue in SelectedIndexChanged

15 posts, 0 answers
  1. Doug Odegaard
    Doug Odegaard avatar
    51 posts
    Member since:
    Oct 2004

    Posted 24 Mar 2008 Link to this post

    1     protected void ddlMake_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)  
    2     {  
    3         ViewState["Make"] = e.Text;  
    4     } 

    Forgive me if this is an extremely easy question but for some reason I cannot get the SelectedValue rather than the SelectedText from the RadCombo in the SelectedIndesChanged event.  Can someone please help me find where this may be?  e.Text is the only thing that appears to be accessible.  My ID values are the hidden piece I need.

    Thanks in advance.
    Doug

  2. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 25 Mar 2008 Link to this post

    Hello Doug Odegaard,

    Please try using RadComboBox.SelectedValue property in the event handler to get the value of the currently selected item.

    Please let me know how it goes.

    Sincerely yours,
    Simon
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Doug Odegaard
    Doug Odegaard avatar
    51 posts
    Member since:
    Oct 2004

    Posted 25 Mar 2008 Link to this post

    It returns a null.  I am using this with your LoadOnDemand demo example.  I basically need to get the underlying value once someone has chosen a value.  All I can see is that it is very "display text" centric.

    Thanks.
    Doug
  5. Steele
    Steele avatar
    58 posts
    Member since:
    Jun 2006

    Posted 25 Mar 2008 Link to this post

    I need this functionality as well...

    I would expect the RadComboBoxSelectedIndexChangedEventArgs to include .Text, .Value and .Index properties at the least.

    .SelectedIndex() is essential in my understanding of how to make synchronized comboboxes work properly via AJAX.

    If I had a selected Index collection, I could use the NeedsDataSource to rely on the data being populated during the ajax call, even if it is reloaded.

    Having support for Multiselection, i.e. SelectedIndex() instead of .SelectedIndex is important as well.

    to further expand on this...

    I have a radComboBox on a Master Page.
    The Master Page has a RadAjaxManager
    The radComboBox is set to AutoPostBack=True
    The AjaxManager is set so that FacilitySelector Updates FacilitySelector

    This code does not work...

    Private Sub FacilitySelector_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles FacilitySelector.SelectedIndexChanged

    Dim cbo = TryCast(o, Telerik.Web.UI.RadComboBox)

    If cbo IsNot Nothing Then

    Try

    If Session("FacilityUID") <> CInt(cbo.SelectedValue) Then

    Session("FacilityUID") = CInt(cbo.SelectedValue)

    End If

    Catch ex As Exception

    End Try

    End If

    End Sub


    The FIRST time it does in fact work, it sets the sessionvar and updates the control.

    Subsequent Changes do NOT work because the SelectedIndex is always the same, the first item selected.

    I have tried setting EnableViewState both ways, and various other things but I cannot access he newly selected item after the first selection.

    I DO NOT want to do this with JavaScript, this should be a server-side function that works with AjaxManager.

    e.Text is Correct showing the newly selected text and so does the following code, but this just seems like a Kludge since e.Text is not considered Unique (but in fact "most likely is" in my particular case).

    Private Sub FacilitySelector_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles FacilitySelector.SelectedIndexChanged

    Dim cbo = TryCast(o, Telerik.Web.UI.RadComboBox)

    If cbo IsNot Nothing Then

    Try

    Dim item As Integer = cbo.FindItemIndexByText(e.Text)

    cbo.SelectedIndex = item

    If Session("FacilityUID") <> cbo.SelectedValue Then

    Session("FacilityUID") = cbo.SelectedValue

    End If

    Catch ex As Exception

    End Try

    End If

    End Sub

  6. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 28 Mar 2008 Link to this post

    Hi Steele,

    We have already planned the implementation of the RadComboBox's Value as a property of the SelectedIndexChanged event arguments. However, the addition of the Index property needs further consideration.

    Now, to your specific case. I created a sample project using the configuration you have described. It worked as expected. Please see the attached project for a reference.

    Best wishes,
    Simon
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Doug Odegaard
    Doug Odegaard avatar
    51 posts
    Member since:
    Oct 2004

    Posted 31 Mar 2008 Link to this post

    Any date on the implementation of the Value property??  Looks like it was part of the ASP.NET Controls RadCombo previously based on the documentation.
  8. Nikolay
    Admin
    Nikolay avatar
    3997 posts

    Posted 03 Apr 2008 Link to this post

    Hi Doug Odegaard,

    Our developers will surely include this property in the forthcoming Q1 release due by the end of this month. I hope this timeframe is acceptable for you.

    Regards,
    Nick
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. Doug Odegaard
    Doug Odegaard avatar
    51 posts
    Member since:
    Oct 2004

    Posted 03 Apr 2008 Link to this post

    Sounds perfect to me.  I crearted a wild workaround until it is posted.  Thanks Nick!
  10. Kishan A
    Kishan A avatar
    5 posts
    Member since:
    Oct 2009

    Posted 26 Oct 2009 Link to this post

    Hi,
        I am in similar situation where in I need the value of the selected item. Is there anyupdates on this?
    "RadcomboBox.SelectedValue" gives the text but not the corresponding value.
  11. Casey
    Casey avatar
    299 posts
    Member since:
    Jul 2009

    Posted 26 Oct 2009 Link to this post

    Kishan,

    Are you trying to find the value during the SelectedIndexChanged event? If so, I find that the below code works for me to return the newly selected value. Also, you may want to ensure that your DataValueField is setup to be the field you wish to return. It sounds like maybe your DataValueField and DataTextField properties are setup to be against the same field from the datasource.

     

    protected void RadComboBox1_SelectedIndexChanged(object source, RadComboBoxSelectedIndexChangedEventArgs e)  
        {  
            string comboValue = e.Value;  
        } 

    I hope this helps,
    Casey
  12. Kishan A
    Kishan A avatar
    5 posts
    Member since:
    Oct 2009

    Posted 26 Oct 2009 Link to this post

    Hey Casey,
        Thanks a ton!!I'm relieved.....It worked!!!!
    Cheers,
    Kishan
  13. Pravallika
    Pravallika avatar
    30 posts
    Member since:
    Mar 2014

    Posted 16 Jun 2014 in reply to Casey Link to this post

    its not working for me radcombobox1.text is working means corresponding text is coming but e.value is not coming and in debugging value is showing empty
  14. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Jun 2014 in reply to Pravallika Link to this post

    Hi Pravallika,

    Such an issue is not expected, please make sure that you have mentioned the Value for the items in the RadComboBox. Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadComboBox ID="rcboCountry" runat="server" EmptyMessage="--select--" DataSourceID="SqlDataSource1" AutoPostBack="true" DataTextField="CountryName" OnSelectedIndexChanged="rcboCountry_SelectedIndexChanged" DataValueField="CountryId">
    </telerik:RadComboBox>

    Please provide your full code if it doesn't help.
    Thanks,
    Shinu.
  15. Pravallika
    Pravallika avatar
    30 posts
    Member since:
    Mar 2014

    Posted 16 Jun 2014 in reply to Shinu Link to this post

    <telerik:RadComboBox ID="cmbItemMaster" Width="90%"  AutoPostBack="true" runat="server"
                                          AllowCustomText="true" Filter="Contains" EmptyMessage="select" OnSelectedIndexChanged="cmbItemMaster_SelectedIndexChanged"
                                        ></telerik:RadComboBox>
     
     protected void LoadItemMaster()
           {
               cmbItemMaster.DataSource = objItemMasterDAO.GetAllItemMasters();
               cmbItemMaster.DataValueField = "ItemMasterID";
               cmbItemMaster.DataTextField = "ItemMasterName";
               cmbItemMaster.DataBind();
           }
    protected void cmbItemMaster_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
           {
               if (e.Value != "")
               {
                   LoadItemMaster(e.Value);
               }
          }
    when i wrote cmbItemMaster.Text  here i am getting the value but in e.value showing null
  16. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Jun 2014 in reply to Pravallika Link to this post

    Hi Pravallika,

    Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadComboBox ID="rcboItems" runat="server" AllowCustomText="true" Filter="Contains"
        EmptyMessage="select" AutoPostBack="true" OnSelectedIndexChanged="rcboCountry_SelectedIndexChanged">
    </telerik:RadComboBox>

    C#:
    protected void Page_init(object sender, EventArgs e)
    {
        rcboItems.DataSource = GetData();
        rcboItems.DataValueField = "ItemMasterID";
        rcboItems.DataTextField = "ItemMasterName";
        rcboItems.DataBind();
    }
    protected DataTable GetData()
    {
        DataTable dtcboItems = new DataTable();
        dtcboItems.Columns.Add(new DataColumn("ItemMasterID"));
        dtcboItems.Columns.Add(new DataColumn("ItemMasterName"));
     
        dtcboItems.Rows.Add(new object[] { 1, "Canada" });
        dtcboItems.Rows.Add(new object[] { 2, "Saudi Arabia" });
        dtcboItems.Rows.Add(new object[] { 3, "Mexico" });
        dtcboItems.Rows.Add(new object[] { 4, "Venezuela" });
     
        return dtcboItems;
    }
    protected void rcboCountry_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
    {
        string selectedValue = e.Value;
    }

    Thanks,
    Shinu.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017