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

Databound Dropdownlist - How say if null then 0

In my databound datagrid i have a databound dropdownlist, like this:

<asp:DropDownList ID="ddlAvail0" runat="server"
SelectedValue='<%# Bind("AvailMon") %>'>
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:DropDownList>

I would really prefer to use a checkbox, but because it doesn't have a 3rd
state for null I'm stuck using a dropdownlist.

Anyway, when the user is going to INSERT a new person the ddl defaults to
the first item, which is null.

Is there anyway to save 0 to the database automatically if the first
listitem is selected? I didn't have to write any code yet - just using the
designer.

I hope this makes sense.

Thanks for your advice!
Jun 27 '08 #1
2 1661
set the first item to <asp:ListItem value="0"></asp:ListItem>
or use isNull(@ddlparampassedin, 0) in your insert statement. Assuming you
are using sqlserver.

--
Share The Knowledge. I need all the help I can get and so do you!
"Cirene" wrote:
In my databound datagrid i have a databound dropdownlist, like this:

<asp:DropDownList ID="ddlAvail0" runat="server"
SelectedValue='<%# Bind("AvailMon") %>'>
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:DropDownList>

I would really prefer to use a checkbox, but because it doesn't have a 3rd
state for null I'm stuck using a dropdownlist.

Anyway, when the user is going to INSERT a new person the ddl defaults to
the first item, which is null.

Is there anyway to save 0 to the database automatically if the first
listitem is selected? I didn't have to write any code yet - just using the
designer.

I hope this makes sense.

Thanks for your advice!
Jun 27 '08 #2
awesome thanks!

"Yankee Imperialist Dog" <Ya******************@discussions.microsoft.com>
wrote in message news:ED**********************************@microsof t.com...
set the first item to <asp:ListItem value="0"></asp:ListItem>
or use isNull(@ddlparampassedin, 0) in your insert statement. Assuming you
are using sqlserver.

--
Share The Knowledge. I need all the help I can get and so do you!
"Cirene" wrote:
>In my databound datagrid i have a databound dropdownlist, like this:

<asp:DropDownList ID="ddlAvail0" runat="server"
SelectedValue='<%# Bind("AvailMon") %>'>
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:DropDownList>

I would really prefer to use a checkbox, but because it doesn't have a
3rd
state for null I'm stuck using a dropdownlist.

Anyway, when the user is going to INSERT a new person the ddl defaults to
the first item, which is null.

Is there anyway to save 0 to the database automatically if the first
listitem is selected? I didn't have to write any code yet - just using
the
designer.

I hope this makes sense.

Thanks for your advice!

Jun 27 '08 #3

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

Similar topics

2
by: anastasia | last post by:
I have the following code (this is a snippet): InitDBConn(); OpenDBConnection(); OleDbCommand cmdRidge = new OleDbCommand("SELECT * FROM TRDRidgeTypes", oleDbConn); OleDbDataReader...
6
by: dbuchanan | last post by:
VS2005 I've been reading all the help I can on the topic (MSDN, other) but I can't make sense of this. Desired behavior; The user is to choose from the displayed list of the databound combobox...
9
by: Jakob Lithner | last post by:
1) I have a DataGridView with edit capability. But in some columns I want to limit the input with a DropDownList. There is no inbuilt column for DropDownLists so I intended to add one myself. I...
2
by: cider123 | last post by:
I have a SqlDataSource bound to a DropDownList Combo. Works just fine. I noticed 2 properties you can set in the DropDownList, 1 for the value to be displayed in the "Text" column and 1 for the...
1
by: DJ | last post by:
I have a DropDownList in Visual Web Developer that is databound to a SQL Database. Whenever the web page is opened the DropDownList is automatically filled with the first item in the table. My...
5
by: maurban | last post by:
Hi there experts, I have a gridview with a couple textboxes and a dropdownlist. I'm trying to insert a default value into my database driven dropdownlist. I'm doing this in the rowdatabound...
0
by: Mark Micallef | last post by:
Hi, I'm having a problem using a databound dropdownlist inside a reorderlist ajax control. Here's a snippet of the code I'm using: <InsertItemTemplate> <div class="insertArea">...
1
by: Mark Micallef | last post by:
Hi, this question relates to a control in the Ajax toolkit for asp.net 2. I'm having a problem using a databound dropdownlist inside a reorderlist ajax control. Here's a snippet of the code I'm...
5
by: nzkks | last post by:
Hi I am using these: ASP.Net 2.0, VB.Net, Visual Studio 2005, SQL Server 2005, Formview controls In a ASP.Net form I have 20 textboxes and 20 dropdownlists(ddl). All ddl(s) are databound and get...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.