hi!
i am using listbox control to bind the one column data. in sql server i take one table like Emp. in that table "Ename" column data is bind into the listbox control. i done in web application. but in windows applications how to write the code to do this. i write code in web applications like.
listbox1.datasource = ds.tables[0];
listbox1.datatextfield = "Ename";
listbox1.databind();
Please give a code to do this.
thanks.
Loading

VasanthRank #1,487 · 1.1K reputationPosted Apr 5, 2010, 11:00 PM EDT
listbox1.DataSource = ds.Tables["
listbox1.DisplayMember = "Ename";
Please mark as answer , if it helps you.
ajay rajuRank #4,639 · 333 reputationPosted Apr 8, 2010, 3:32 AM EDT
hi! Vasanth Thank u for giving Replay. if u don't mine also give acode for doing data bind in CheckedListBox in Windows Application.
i am waiting for ur replay.
Thank u.
VasanthRank #1,487 · 1.1K reputationPosted Apr 8, 2010, 10:23 PM EDT
Here just we cast from checkedlistbox to listbox .
//Create temp datatable for bind values
DataTable dtTemp = new DataTable(); DataRow dr;
//create schema
dtTemp.Columns.Add("Eid"); dtTemp.Columns.Add("Ename");
//Add temp datas
dr = dtTemp.NewRow(); dr["Eid"] = "1"; dr["Ename"] = "CAAA"; dtTemp.Rows.Add(dr);
dr = dtTemp.NewRow(); dr["Eid"] = "2"; dr["Ename"] = "CBBB"; dtTemp.Rows.Add(dr);
dr = dtTemp.NewRow(); dr["Eid"] = "3"; dr["Ename"] = "CCCC"; dtTemp.Rows.Add(dr);
dr = dtTemp.NewRow(); dr["Eid"] = "4"; dr["Ename"] = "CDDD"; dtTemp.Rows.Add(dr);
dr = dtTemp.NewRow(); dr["Eid"] = "5"; dr["Ename"] = "CEEE"; dtTemp.Rows.Add(dr);
//Just u cast here
(checkedListBox1 as ListBox).DataSource = dtTemp;
(checkedListBox1 as ListBox).DisplayMember = "Ename";
(checkedListBox1 as ListBox).ValueMember = "Eid";
Please mark as answer , if it helps you.