This is a migrated thread and some comments may be shown as answers.

Erroneous Value Property Upon SelectedIndexChanged

2 Answers 115 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 13 Dec 2012, 05:57 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 13 Dec 2012, 06:44 AM
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.
0
Robert
Top achievements
Rank 1
answered on 14 Dec 2012, 10:57 PM
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.
Tags
ComboBox
Asked by
Robert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Robert
Top achievements
Rank 1
Share this question
or