473,378 Members | 1,415 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

dropdown list and databinding issue

69
hi guys,

I am using Visual Studio 2005. I have a dropdown list that has an associated SQLdatasource. I also have a textbox below the dropdown list that allows you to add items to the table that the datasource is associated with.After entering a new item into the table that the datasource is tied to, i would like to "refresh" the dropdown list so this is what i did

manuDropDownList.Items.Clear();
manuDropDownList.DataBind();


my problem is that i have the first item in the dropdown list as SELECT... and i set AppenddataBoundItems=true in the drop down list properties however after databinding and stuff the SELECT... does not show up.
Everything works fine except that the SELECT... does not come back
How do i get it back?

please help
Apr 28 '08 #1
2 1373
shweta123
692 Expert 512MB
Hi,

Please check that if you have added "Select.." string into dropdownlist at the time of refreshing it.
e.g.

Expand|Select|Wrap|Line Numbers
  1.  
  2. manuDropDownList.Items.Clear();
  3.  
  4. //Add this statement if you want first item as "Select"
  5. manuDropDownList.Items.Add("Select..")
  6. manuDropDownList.DataBind();
hi guys,

I am using Visual Studio 2005. I have a dropdown list that has an associated SQLdatasource. I also have a textbox below the dropdown list that allows you to add items to the table that the datasource is associated with.After entering a new item into the table that the datasource is tied to, i would like to "refresh" the dropdown list so this is what i did

manuDropDownList.Items.Clear();
manuDropDownList.DataBind();


my problem is that i have the first item in the dropdown list as SELECT... and i set AppenddataBoundItems=true in the drop down list properties however after databinding and stuff the SELECT... does not show up.
Everything works fine except that the SELECT... does not come back
How do i get it back?

please help
Apr 29 '08 #2
prabunewindia
199 100+
hi,
Please check, where you placed the code to add "select"

if you wrote this before dropdownlist.DataBaind(), then the add item (i.e, "select") will be deleted when you bind the datasource.

so please add the item after bind.

Its better to use,

dropdownlist.Items.Insert(0,"select"); than add...

Rajendra Prabu Elias
Apr 29 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Kris Rockwell | last post by:
Hello, I have done the following to bind data to a DropDown box: 1. Drag SQLServer table onto web form to create data connection and data adapter. 2. Generate dataset by right-clicking on...
2
by: DotNetJunkies User | last post by:
hi,, im trying to work out what code is needed for the below problem about databinding a dropdown list and having actual datalist items as value "0" ie 'please select' can anyone tell me how to...
4
by: Merdaad | last post by:
Hi, In my dropdown I bind to a datasource. After that I try to do one of the following: 1. Add an Item to the dropdown using dd.Items.Add(newe ListItem("textstr")); 2. Change the text of an...
0
by: Pietje puk | last post by:
Hello, Since im quite new to ASP.NET i wanted to ask you folks what the best way is to create a WebForm for modifying 1 field from a record. The manipulation of this field can be done by using...
2
by: Waran | last post by:
I Want to add a dropdown box in a datagrid on Page_Load. This Datagrid shares two tables. One table contains Employee details, and the other having the list of projects the employee is...
5
by: jung_h_park | last post by:
From: jung_h_park@yahoo.com Newsgroups: microsoft.public.dotnet.framework.aspnet Subject: Dropdown List not retaining its SelectedValue Date: Mon, 26 Jun 2006 21:02:57 -0700 Hello, My...
0
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
2
by: cmay | last post by:
A common situation I come across is an ASCX control that being used as a lookup control. The ascx might be called "StatusLookup" or something, and it consists of 1 dropdown list that populates...
8
by: Wingot | last post by:
Hey, I have a program I am trying to write using Visual C#, SQL Server 2005/2008, and Visual Studio 2008, and one part of it includes a Schema called Client. Inside this schema, three tables...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.