Codeasearch.com - Search your code with us Login | Register | Contact us
  Forums > Asp.Net > Drop down box
manikandan
Posted on Aug 14, 2007
Join Date: August 2007
Location: India ( Chennai )
Posts: 8
 
Drop down box  

Hi frndz,

Iam getting the value dynamically to dropdown box, how could i add Select at the top of the drop down.

thanks,

manikandan. k

raghunath
Posted on Aug 14, 2007
Join Date: August 2007
Location: India ( Chennai )
Posts: 3
 
DropDown  

Mani,
You can add a option tag like this.
yourselectboxname.Items.Add(new ListItem(\"text\", \"value\"));

benaya
Posted on Aug 14, 2007
Join Date: June 2007
Location: India ( Chennai )
Posts: 90
 
Re: Drop down box  

Hi,
Friend check out script below... its working nice for me.

conn.Open();
SqlCommand mycommanddis = new SqlCommand("select VLocation from table where VPublication='MainSite' group by VLocation", conn);

selLocation.Items.Add("--Select--");
selLocation.DataTextField = "VLocation";
selLocation.DataValueField = "VLocation";
selLocation.DataSource = mycommanddis.ExecuteReader();
selLocation.DataBind();
selLocation.Items.Add("--Select--");

if (Request["chkID"] != "")
{
selLocation.SelectedValue = Request["selLocation"];
}
else
{
selLocation.SelectedValue = "--Select--";
}
conn.Close();

 Hot Discussion
Go Tech launches Android tablet for Rs 3,999...
Sony targets retailers with quick sales pitches and rew...
Share and discover new activities with Google Schemer...
Samsung gets 9 mn preorders for Galaxy S3: Report...
Google revamps search engine to think like a person...
 
 Discussion Topics
IT News
Php
Javascript
Technology Updates
Asp.Net
MySql
Ajax
Html
Fedora
Software Testing
Asp
Java
General
Flash
Ruby on Rails