bind data to html dropdownlist

Posted by Venkatesh under C# on 11/23/2010 | Points: 10 | Views : 14888 | Status : [Member] | Replies : 3
Hi,

How to bind data to html dropdownlist control using c#. The data will be coming from database.

How to do this.




Responses

Posted by: T.saravanan on: 11/23/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Venkatesh,

In your source page set in HTML Select control runat="server"
<select id="ddlDrop" runat="server> </select>


Your code behind:
Get the value into DataTable
Here dtData --> Your DataTable
ddlDrop.DataSource= dtData.Copy();

ddlDrop.DataValueField="ID";
ddlDrop.DataTextField="Name";
ddlDrop.DataBind();


Try this way...

Cheers :)

Thanks,
T.Saravanan

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Venkatesh on: 11/23/2010 [Member] Starter | Points: 25

Up
0
Down
Hi,

Thanks for replying. Now, i want add checkboxes in the same dropdown how to achieve this.

Venkatesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response