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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Abhineet SrivastavaRank #1,890 · 783 reputationPosted Aug 5, 2013, 4:29 AM EDT
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-", ""));
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 5, 2013, 6:02 AM EDT
Try like this
Regards,
Iftikar
Sanjeeb LenkaRank #301 · 8.3K reputationPosted Aug 5, 2013, 6:38 AM EDT
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