Click here to Skip to main content
15,907,000 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
dear sir

i have a dropdownlist i want to a default value and also other value in asp.net

thanks in advance
Posted

Hi,
UploadSP spUpload = new UploadSP();
ddlStudent.DataSource = spUpload.StudenntNameViewForUploadingFile(Decimal.Parse(ddlClass.SelectedValue.ToString()),ddlDivision.Text);
ddlStudent.DataTextField = "studentName";
ddlStudent.DataValueField = "studentId";
ddlStudent.DataBind();
ddlStudent.Items.Insert(0, "--Select--");
 
Share this answer
 
Hi Dinesh

below Code will you to resolve your query

DataRow dr = ds.Tables[0].NewRow();
dr["CityName"] = "Select City";
dr["CityID"] = "0";
ds.Tables[0].Rows.InsertAt(dr, 0);
Dropdownlist.DataTextField = "CityName";
Dropdownlist.DataValueField = "CityID";
Dropdownlist.DataSource = ds;
Dropdownlist.DataBind();
 
Share this answer
 
What is your datatable Fields to Identify Default Columns
 
Share this answer
 
Comments
m@dhu 20-Aug-11 2:38am    
This should be a question rather than answer. Use Have a Question or Comment? when you have a question to op. :)

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