473,659 Members | 3,117 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dropdown list and databinding issue

69 New Member
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

manuDropDownLis t.Items.Clear() ;
manuDropDownLis t.DataBind();


my problem is that i have the first item in the dropdown list as SELECT... and i set AppenddataBound Items=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 1389
shweta123
692 Recognized Expert Contributor
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

manuDropDownLis t.Items.Clear() ;
manuDropDownLis t.DataBind();


my problem is that i have the first item in the dropdown list as SELECT... and i set AppenddataBound Items=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 New Member
hi,
Please check, where you placed the code to add "select"

if you wrote this before dropdownlist.Da taBaind(), 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.It ems.Insert(0,"s elect"); 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
278
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 the data adapter ad selecting generate dataset.
2
2408
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 do this in relation to the below code,, thanks paul.
4
1524
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 existing item in the dropdown. For this one I use the following:pubDD.Items.Text=otherText; Neither one works.
0
1295
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 dropdown list. Previously i've written a lot of these page's by not using the webcontrols, but now i've reached this magically moment that i want to try these features. :D
2
1215
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 working. Table 1 ------- Name DOB Address
5
11891
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 dropdown list control does not retain its SelectedValue. Unless I read the SelectedValue right after the control has been loaded, populated, and assigned with its original value (and of course that is
0
2906
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 strDataValueField; string strDataTextField; public CreateEditItemTemplateDDL(string DDLName,string DataValueField,string
2
2109
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 itself from cache/database list. If you databind on the Init event, then you are databinding every time, and not making any use of the viewstate. If you databind on the Load event, you can see if the control has
8
2930
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 exist named Country, MedicalCondition, and Customer.
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.