开发者

Bind RadComboBox to ObjectDataSource using DataSet

I'm try开发者_JAVA技巧ing to bind a RadComboBox to an ObjectDataSource whose select method returns a DataSet object. I get an error: "'FieldName', is neither a DataColumn nor a DataRelation for table Table". Just to be sure I'm not crazy, I tried the same with a DropDownList which worked perfectly. I found in Telerik's docs that they support using an ObjectDataSource that returns IEnumerable objects. So, am I correct that the RadControls don't support using ObjectDataSource when it is using a DataSet? Really?


The link you provided points to a different control. See here for the combobox, which is the control in your question title.

The combobox control easily accepts datatable objects from datasets as a source of what to display in the combobox.

Bind RadComboBox to ObjectDataSource using DataSet

Then the combobox control:

Bind RadComboBox to ObjectDataSource using DataSet

Select the GetData method (the only option) and then configure your combobox:

Bind RadComboBox to ObjectDataSource using DataSet

Run:

Bind RadComboBox to ObjectDataSource using DataSet

EDIT:

There seems to be no reason to use a ObjectDataSource if you are already using a dataset and SqlDataAdapter :

    DataSet myDataset = new DataSet();

    SqlConnection con = new SqlConnection(@"Data Source=J-PC\SQLEXPRESS;Initial Catalog=SO;Integrated Security=True");

    SqlDataAdapter adapter = new SqlDataAdapter(@"SELECT TOP (25) Leg_FirstName FROM GRS_Legislator ORDER BY Leg_FirstName", con);

    adapter.Fill(myDataset);

    RadComboBox1.DataTextField = "Leg_FirstName";
    RadComboBox1.DataValueField = "Leg_FirstName";
    RadComboBox1.DataSource = myDataset;
    RadComboBox1.DataBind();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜