Hi
Guide me in linking the dropdownlist to the sql server table
Thanks
Kritika
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sanjeeb LenkaPosted Aug 5, 2013, 10:38 AM
for asp.net refer to this link
http://www.aspdotnet-suresh.com/2012/10/showbind-data-to-aspnet-dropdownlist.html
http://www.webcodeexpert.com/2013/02/how-to-fill-dropdownlist-from-sql.html
for Windows form refer to this link
http://dotnetsridhar.blogspot.in/2012/04/binding-combobox-in-windows.html
http://imagirlit.blogspot.in/2013/02/load-data-into-combobox-in-c-from-sql.html
Iftikar HussainPosted Aug 5, 2013, 10:02 AM
Try like this
Regards,
Iftikar
Abhineet SrivastavaPosted Aug 5, 2013, 8:29 AM
Use Like this-
1-First get Value in Datatable from Database-
objsco = new clsSponsoringComp();
objsco.strMa_id = Session["maid"].ToString();
DataTable dtsco = objsco.SelectSponsoringcompany();
2-Bind Dropdown like this-
ddlcompany.DataSource = dtsco;
ddlcompany.DataTextField = "name";
ddlcompany.DataValueField = "sco_id";
ddlcompany.DataBind();
ddlcompany.Items.Insert(0, new ListItem("-Select Company-", ""));