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

Set selected value in code behind

4 Answers 170 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Saeid Kdaimati
Top achievements
Rank 2
Saeid Kdaimati asked on 13 Mar 2013, 02:07 PM
Hi,

Just trying to set the selected value of combobox in code behind, but it is not working out:
RadComboBox1.DataSource = ds.Tables[0];
RadComboBox1.DataTextField = "Text";
RadComboBox1.DataValueField = "ID";
RadComboBox1.DataBind();
if (ds.Tables[1].Rows.Count > 0)
{
  RadComboBox1.SelectedValue = ds.Tables[1].Rows[0]["ID"].ToString();
}

The stored procedure I'm calling return correct data.

Any help??

4 Answers, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 13 Mar 2013, 04:33 PM
Hi Saeid,

The code you posted seems to be correct. Please check returned data from the Stored Procedure once again. I'm attaching  a small sample demonstrating how this code works as expected.

All the best,
Hristo Valyavicharski
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Dev
Top achievements
Rank 1
answered on 13 Mar 2013, 05:23 PM
If you take your example and use Tools -> Generate Local Resource on Default.aspx in design view, SelectedValue has no effect and a blank selection is added at the top of the ComboBox.
0
Hristo Valyavicharski
Telerik team
answered on 18 Mar 2013, 04:35 PM
Hello,

Thank you for pointing this out. This is a development issue, which I have logged for further investigation.

Regards,
Hristo Valyavicharski
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Peter Filipov
Telerik team
answered on 02 Jul 2013, 10:56 AM
Hi Rob,

The issue with the creation of the default item when local resources are created will be resolved in Q2.2013 SP1.

Regards,
Peter Filipov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
ComboBox
Asked by
Saeid Kdaimati
Top achievements
Rank 2
Answers by
Hristo Valyavicharski
Telerik team
Dev
Top achievements
Rank 1
Peter Filipov
Telerik team
Share this question
or