tags:

views:

34

answers:

1

How Can I (Or Is It Possible?) Add Item to Html Combobox ServerSide ? Or Bind It in behind Code in asp.net ? Does My question Clear?

+2  A: 

Do you want to modify a HTML select tag in code behind?

If yes, here is what you need to do:

  1. Add runat=server in your tag (<select id="s1" runat="server">)
  2. To bind the control server side, use a datasource (a datatable for example), set the datasource s1.DataSource = dt set the property s1.DataTextField to the property of the datasource you want to bind as the text shown to the user, the s1.ValueTextField to the property of the datasource to use as the value, and call the s1.Databind() method
  3. To add/remove items (options) you can call s1.Items.Add/AddRange/Insert/Remove/RemoveAt method.
GôTô
No i cant add runatserver to my tag because i want to use it with jquery autocomplete http://stackoverflow.com/questions/3948024/bind-asp-net-server-side-data-to-html-combobox
shaahin
@shaahin: I don't understand, could be more explicit? What is the matter with jquery autocomplete? How exactly do you want databinding to work? Request data from server via jQuery?
GôTô