473,586 Members | 2,839 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dropdown binding with datalist value of zero for please select...

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.
>>>>>>>>>


So I'm guessing that this behavior is by design??

I was able to Insert a row after the bind and that works!

Thanks!
Andrea
"bruce barker" <no***********@ safeco.com> wrote in message
news:uI******** ******@tk2msftn gp13.phx.gbl...
in the codebehind, add it after the bind

-- bruce (sqlwork.com)
"Andrea Williams" <an*******@hotm ail.IHATESpam.c om> wrote in message
news:#x******** ******@TK2MSFTN GP11.phx.gbl...
I have a drop down control that I've added a list item that has a value

of zero and the text name is "[Select One]". And it shows up like it's
supposed to until I bind a dataset to it. The binding seems to remove the list Item that I added. Is there something I have to set to keep the list Item that I added via ASPX code? Has anyone been successful in having a
defuatl selection that is not in the data set?

ASPX code:
<asp:DropDownLi st id="cboConferen ceID" runat="server" AutoPostBack="T rue"> <asp:ListItem Value="0">[Select One]</asp:ListItem>
</asp:DropDownLis t>

ASP C# code-behind:
this.cboConfere nceID.DataSourc e = dsGeneric;
this.cboConfere nceID.DataTextF ield = vstrDataTextFie ld;
this.cboConfere nceID.DataValue Field = vstrDataValueFi eld;
this.cboConfere nceID.DataBind( );

Thanks in advance,
Andrea

PS: VS.NET 2003 on WIN 2000


---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 18 '05 #1
2 2407
Hi paul
I am not sure if i ve got you right but if you want to add an item to the dropdown control then you can use the following cod
Dim lstItem As New ListIte
lstItem.Text = "Please Select
lstItem.Value = "0
DropDownList1.I tems.Add(lstIte m
regard
srini
Nov 18 '05 #2
Hi

Or create a temp table and insert 0,'Please select' then insert the other
stuff into the table

Something like this ( sql SP )
CREATE Table #ItemsTemp
(
ID int,
sText varchar(255)
)
INSERT #ItemsTemp (ID,sText) VALUES(0,'Pleas e select')
INSERT #ItemsTemp SELECT ID,sText FROM MYTABLE ORDER By sText

SELECT ID,sText FROM #ItemsTemp

Not tested but should do the trick...

--
Best Regards
Vidar Petursson
=============== ===============
Microsoft Scripting MVP
http://www.microsoft.com/technet/scriptcenter
=============== ===============
"DotNetJunk ies User" <User@-NOSPAM-DotNetJunkies.c om> wrote in message
news:O$******** *****@TK2MSFTNG P09.phx.gbl...
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.
>>>>>>>>> >

So I'm guessing that this behavior is by design??

I was able to Insert a row after the bind and that works!

Thanks!
Andrea
"bruce barker" <no***********@ safeco.com> wrote in message
news:uI******** ******@tk2msftn gp13.phx.gbl...
in the codebehind, add it after the bind

-- bruce (sqlwork.com)
"Andrea Williams" <an*******@hotm ail.IHATESpam.c om> wrote in message
news:#x******** ******@TK2MSFTN GP11.phx.gbl...
> I have a drop down control that I've added a list item that has a value

of > zero and the text name is "[Select One]". And it shows up like it's
> supposed to until I bind a dataset to it. The binding seems to remove the > list Item that I added. Is there something I have to set to keep the list > Item that I added via ASPX code? Has anyone been successful in having a
> defuatl selection that is not in the data set?
>
> ASPX code:
> <asp:DropDownLi st id="cboConferen ceID" runat="server" AutoPostBack="T rue"> > <asp:ListItem Value="0">[Select One]</asp:ListItem>
> </asp:DropDownLis t>
>
> ASP C# code-behind:
> this.cboConfere nceID.DataSourc e = dsGeneric;
> this.cboConfere nceID.DataTextF ield = vstrDataTextFie ld;
> this.cboConfere nceID.DataValue Field = vstrDataValueFi eld;
> this.cboConfere nceID.DataBind( );
>
> Thanks in advance,
> Andrea
>
> PS: VS.NET 2003 on WIN 2000
>
>


---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup
engine supports Post Alerts, Ratings, and Searching.

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
5246
by: J P Singh | last post by:
Hi There We have dropdown on ASP page. The problem is we have about 900 items in the dropdown. Users scrolling through the list have become very frustrated in the past. Can someone suggest if there is another way of implement a dropdown where the datalist is as big as ours. I am looking for something like a listbox in VB where you can...
10
2284
by: JL | last post by:
Does anyone have any ideas on this please? I don't know how to evaluate the no-blank selections against each other from a form as follows: . I have a form with 6 dropdown fields, each containing a selection of 30 options (the 30 options are the same for each dropdown list). The user needs to select 'one of the 30 options' from each...
0
2000
by: Mark | last post by:
Hi, I have a datalist that contains a textbox as well as a dropdown list. For each single row in the datalist the associated dropdown list can have at least one value What I would like to be able to do is when a single update button is clicked the textbox value along with the associated dropdown value is printed for each row in the...
4
1951
by: Brian Conway | last post by:
I need some help on binding a datareader to a dropdown box. I have included the code for the dropdown below. It builds with no errors, but returns no results. Any help would be appreciated. private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e) { OleDbConnection conn = new...
5
1890
by: Laura K | last post by:
I am having difficulty binding data to my datalist. The data list does not show. I have gone round and round for two days. I could really use some help looking through this code and seeing where the error is. It is usually something simple but I just can not find it!!! Any suggestion? ...
3
4418
by: devNorway | last post by:
I have been struggling with a problem for days now, and searched for related problems and solutions but had no luck. I have two dropdown listboxes where the first is populated in page load and the second is populated based on the input in the first. The first dropdown is inside a "If Not Page.IsPostBackThey" if loop. Both have autopostback...
2
3616
by: Jason James | last post by:
Hi, I have a datalist that contains a series of thumbnails. I am in the process of paging this datalist so that only 20 images are displayed at a time. Each image has associated with it a pair of dropdown boxes. The user selects theor choices from the dropdown boxes and then moves to the next series of 20 images. The postbackURL of the...
1
2699
by: SunshineInTheRain | last post by:
The following code is dynamic create dropdownmenu which data within pulled from database However, the code work well on IE but not on Firefox. On Firefox, the whole mouseover and mouseout function din't work. what is not supported on Firefox? the javascript syntax? please help as i am not familiar with javascript. thanks in advanced. this is...
2
2209
coolv
by: coolv | last post by:
Hello I have problem in my page that the dropdown box is not displaying data according to selection of first dropdown.Please help me. Below is my code. thanks.............. <?php session_start(); if (!isset($_SESSION)) {
0
7911
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...
1
7954
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...
0
8215
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...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
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...
0
3864
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2345
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
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.