Click here to Skip to main content
15,997,744 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to bind data coming from sql server database into dropdown of html 5 with text and value format like asp.net dropdown list ( two table coulmn bind into single dropdown item) .

i have a table into sql server and i wanto to show two coumn of every row into dropdown int html 5 page with text and value formate like in asp.net web pages (aspx page). is it possible to bind two column of data table into single dropdown list of html dynamcally . ???
Posted

1 solution

Get data from sql server through data source(ds) and bind it with dropdown list e.g
ddl->dropdown list name in html
ds->data source for dynamically getting data from server
tl->name of the table
city and cityCode->two column of a table
ddl.DataSource = ds.Tables["tl"];
ddl.DataTextField = ds.Tables["tl"].Columns["city"].ColumnName.ToString();
ddl.DataValueField = ds.Tables["tl"].Columns["cityCode"].ColumnName.ToString();
ddl.DataBind();

I hope this may help you!!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900