CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.portal_starter_kit Tags:
Item Type: NewsGroup Date Entered: 8/28/2003 12:23:11 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 3 Views: 91 Favorited: 0 Favorite
4 Items, 1 Pages 1 |< << Go >> >|
fuzzygoth
Asp.Net User
null value in a asp:DropDownList control8/28/2003 12:23:11 PM

0

I pull a list out of the database using the below lines of code the asp:DropDownList Control
but i need the first value in the dropdownlist to be a null value. Is there anyway i can specify
this in the asp:dropdownlist control or what is the best way of doing it ?

< asp:DropDownList id="PosObj" DataTextField="PlayerPos" DataValueField="posid" runat="server" / >

< asp:RequiredFieldValidator ControlToValidate="PosObj" ErrorMessage="'PosObj' must not be left blank." runat="server" / >





davidgmiles
Asp.Net User
Re: null value in a asp:DropDownList control8/28/2003 12:37:57 PM

0

After the databind add

PosObj.Items.Insert(0, New ListItem("Please select a player ...", String.Empty))

Is that the kind of thing that you are after - this means that the first item in the list box will not be a player's name but instead will be the text, "Please select a player ..."

DavidM
Various IBS Addons available at http://www.snowcovered.com

Lead Developer [vb & c#] - MCAD
adec
Asp.Net User
Re: null value in a asp:DropDownList control8/28/2003 12:38:35 PM

0

I would say you should insert a ListItem at index Zero (first item) of the DropdownList. Give this Item the 'value=0'. E.g.:

myDDL.Items.Insert(0, New ListItem("<make a choice>", "0"))

Check for this value when making your DB insert/update:

Dim objDDL As Object

If myDDL.SelectedItem.Value = 0 Then
objDDL = System.DBNull.Value
Else
objDDL = myDDL.SelectedItem.Value
End If

Hth

Regards

Andre Colbiornsen
---------------------------------
[MVP Visual Developer Asp.Net]
Sonnenburg Communications
Friisgatan 33,
SE-214 21 Malm?
Sweden
Mob.: +46-(0)708-97 78 79
Mail: [email protected]
--------------------------------
fuzzygoth
Asp.Net User
Re: null value in a asp:DropDownList control8/28/2003 1:01:25 PM

0

that did exactly what the doctor ordered cheers mate.

I just wanted it to add a blank value in so it could send all the
variable to the sql search query with specifying any search
criteria, and it did exactly that

cheer again mate ;)

-------------------------------------
Fuzzygoth






4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional ASP.NET 2.0 Server Control and Component Development Authors: Shahram Khosravi, Pages: 1186, Published: 2006
Professional ASP.NET 2.0 databases Authors: Thiru Thangarathinam, Pages: 504, Published: 2007
Beginning ASP.NET 2.0 databases: beta preview Authors: John Kauffman, Thiru Thangarathinam, Pages: 404, Published: 2005
ASP.NET data Web controls kick start Authors: Scott Mitchell, Pages: 418, Published: 2003
Microsoft Expression Web 2007 in Depth Authors: Jim Cheshire, Pages: 792, Published: 2008

Web:
ASP.NET.4GuysFromRolla.com: Accessing and Updating Data in ASP.NET ... Data Source Control Basics - explores the concepts and advantages of data .... The CategoryDDL DropDownList includes a list item to capture NULL values. ...
Dropdownlist in a Gridview and the default (null) value problem ... Dropdownlist in a Gridview and the default (null) value problem. To edit a value in ASP.NET 2.0 gridview control you have more options than only a textbox. ...
Handling Null Database Values Using Data Source Controls In many cases, columns in database tables return null when no value is stored in ... However, a null value can present challenges when you are working with ASP. ... The static list item that is added to the DropDownList control has the ...
Reborn: asp.net 2.0 and up: DropDownList in GridView (using ... .... (database schema creation... asp.net 2.0 Roles DropDownList Control in C# ...
Drop Down List Selected Value is Null Problem Drop Down List Selected Value is Null Problem. I am using ASP.net 2.0 and trying to take advantage of the updated data ...

null value in a asp:DropDownList control - ng.asp-net-forum ... null value in a asp:DropDownList control, > ROOT > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.portal_starter_kit, Date: 8/28/2003 12:23:11 ...
DropDownList in a Template (InsertItemTemplate ...) - Include a ... Include a Null Value, > ROOT > NEWSGROUP > Asp.Net Forum ... As far as I know, we cannot add the null value into the dropdownlist control. ...
Bounded DropDownList with Null - ng.asp-net-forum.getting_started ... Often in this situation the data item the DropDownList control is being bound to contains a null value. In these situations the ASP. ...
Custom Validator control: What am I doing wrong? - ng.asp-net ... I'm having an issue with using an control and could use some ... I have a DropDownList control that can be changed to one of 3 values. ...
Dynamically Adding Value to GridView HyperLinkField - general_asp ...






master label change

hide portions of navigation?

masterpage.master

approach to personalising an interface - skins

masterpages with iframe

url & active button

rebind a theme after adding a new css file

asp.net 2.0 menu control problems

treeview nodes backcolor

theming webcontrols - how?

web.sitemap, sitemapdatasource and single link?

treeview and navigateurl problem

page redirection problem

expand and collapse in tree view navigation control

master page, content page -> outputcache doesn't seem to work

master pages version 1.*

stylesheettheme cannot be set programatically?

accessing masterpage properties from a usercontrol on a contentpage??

configuring multiple site maps in the web.config file

asp:menu submenu display control

theme cannot be found in the application or global theme directories

how can i access anyone control on another page?

non-static metadata using master pages?

extending treeview

different set of masterpages for different themes

how to change themes dynamicly?

<form> tag in the master page

dynamic title tag

how can i make autopostback to false of treeview in asp.net 2.0

how to find current node ?

   
  Privacy | Contact Us
All Times Are GMT