Erroneous Value Property Upon SelectedIndexChanged

3 posts, 1 answers
  1. Robert
    Robert avatar
    253 posts
    Member since:
    Aug 2007

    Posted 12 Dec 2012 Link to this post

    To test out the RadComboBox I constructed a simple web page that has just this one control on it.  A small datatable (see attachment) is used to populate the control with this code:

    radList.DataSource = CurrentPasses;
    radList.DataTextField = "Description";
    radList.DataValueField = "Master_Idx";
    radList.DataBind();

    My initial testing has revealed something strange: When I click on any item, the SelectedIndexChanged event is fired.

    protected void radList_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)

    When I check "e.Text" the correct string is shown.  But when I check "e.Value" it always displays -1.  Why isn't it showing the correct "Master_Idx" value for that row?

    Am I missing something or is this a known bug in the RadComboBox?

    Robert
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 13 Dec 2012 Link to this post

    Hi Robert,

    I was able to replicate the issue when the data is bind to the RadComboBox in the Page_Load without having (!Page.IsPostBack). Once I put the databinding in the (!Page.IsPostBack) it worked as expected. Another suggestion is that you can use radList.SelectedValue instead of using e.Value.

    Please elaborate your scenario with your full code if it doesn't help.

    Regards,
    Princy.
  3. Robert
    Robert avatar
    253 posts
    Member since:
    Aug 2007

    Posted 14 Dec 2012 Link to this post

    Thanks, Princy.  Putting the DataBinding code inside of the (!IsPostBack) construct solved the problem.

    I now do have another question but it is quite different so I'll post it in a separate topic.
Back to Top