473,322 Members | 1,480 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,322 software developers and data experts.

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**************@tk2msftngp13.phx.gbl...
in the codebehind, add it after the bind

-- bruce (sqlwork.com)
"Andrea Williams" <an*******@hotmail.IHATESpam.com> wrote in message
news:#x**************@TK2MSFTNGP11.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:DropDownList id="cboConferenceID" runat="server" AutoPostBack="True"> <asp:ListItem Value="0">[Select One]</asp:ListItem>
</asp:DropDownList>

ASP C# code-behind:
this.cboConferenceID.DataSource = dsGeneric;
this.cboConferenceID.DataTextField = vstrDataTextField;
this.cboConferenceID.DataValueField = vstrDataValueField;
this.cboConferenceID.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 2394
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.Items.Add(lstItem
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,'Please 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
==============================
"DotNetJunkies User" <User@-NOSPAM-DotNetJunkies.com> wrote in message
news:O$*************@TK2MSFTNGP09.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**************@tk2msftngp13.phx.gbl...
in the codebehind, add it after the bind

-- bruce (sqlwork.com)
"Andrea Williams" <an*******@hotmail.IHATESpam.com> wrote in message
news:#x**************@TK2MSFTNGP11.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:DropDownList id="cboConferenceID" runat="server" AutoPostBack="True"> > <asp:ListItem Value="0">[Select One]</asp:ListItem>
> </asp:DropDownList>
>
> ASP C# code-behind:
> this.cboConferenceID.DataSource = dsGeneric;
> this.cboConferenceID.DataTextField = vstrDataTextField;
> this.cboConferenceID.DataValueField = vstrDataValueField;
> this.cboConferenceID.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
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...
10
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...
0
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...
4
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. ...
5
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...
3
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...
2
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...
1
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...
2
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 ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.