Search:
Namespaces
Discussions
.NET v1.1
Feedback
Simple question about comboboxes
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspngfreeforall' list
.
Greg Huber
I have a combo box server control. I would like to databind it to one of my
methods. However, I would also like to add "Please Select" with a null value
to the box. What is the best way to do this?
Here is my code:
With cboStatusCode
.DataSource = oEstimate.GetAllEstimateStatusCode
.DataValueField = "ID"
.DataTextField = "Name"
.DataBind()
End With
If I try to add .Items.Add("Please Select") it doesn't work, unless I add it
after the databind which makes sense. Unfortunately, if I do that, it shows
up as the last item in the drop down, and I want it as the first. Is it not
possible to add a "Please Select" using databind if you want it to be the
first item in your combo box? (I realize I could do a for loop in the code
and use the .items.add for each item in my datatable returned by the method
which is the datasource, but that makes things messier)
Thanks,
Greg
Reply to this message...
Matt Serdar
With cboStatusCode
.DataSource = oEstimate.GetAllEstimateStatusCode
.DataValueField = "ID"
.DataTextField = "Name"
.DataBind()
.Items.Insert(0, New
ListItem
("Please Select", "0"))
End With
matt
-----Original Message-----
From: Greg Huber [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, August 07, 2002 12:13 PM
To: aspngfreeforall
Subject: [aspngfreeforall] Simple question about comboboxes
I have a combo box server control. I would like to databind it to one of my
methods. However, I would also like to add "Please Select" with a null value
to the box. What is the best way to do this?
Here is my code:
With cboStatusCode
.DataSource = oEstimate.GetAllEstimateStatusCode
.DataValueField = "ID"
.DataTextField = "Name"
.DataBind()
End With
If I try to add .Items.Add("Please Select") it doesn't work, unless I add it
after the databind which makes sense. Unfortunately, if I do that, it shows
up as the last item in the drop down, and I want it as the first. Is it not
possible to add a "Please Select" using databind if you want it to be the
first item in your combo box? (I realize I could do a for loop in the code
and use the .items.add for each item in my datatable returned by the method
which is the datasource, but that makes things messier)
Thanks,
Greg
| ASP.net DOCS =
http://www.aspng.com/docs
| [aspngfreeforall] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/aspngfreeforall
= JOIN/QUIT
| news://ls.asplists.com = NEWSGROUP
Reply to this message...
chris
Items.Insert(0, "Please Select One");
-Chris Frazier
.NET Solution Developer
Velocity Databank, Inc.
www.velocitydatabank.com
-----Original Message-----
From: Greg Huber [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, August 07, 2002 2:13 PM
To: aspngfreeforall
Subject: [aspngfreeforall] Simple question about comboboxes
I have a combo box server control. I would like to databind it to one of my
methods. However, I would also like to add "Please Select" with a null value
to the box. What is the best way to do this?
Here is my code:
With cboStatusCode
.DataSource = oEstimate.GetAllEstimateStatusCode
.DataValueField = "ID"
.DataTextField = "Name"
.DataBind()
End With
If I try to add .Items.Add("Please Select") it doesn't work, unless I add it
after the databind which makes sense. Unfortunately, if I do that, it shows
up as the last item in the drop down, and I want it as the first. Is it not
possible to add a "Please Select" using databind if you want it to be the
first item in your combo box? (I realize I could do a for loop in the code
and use the .items.add for each item in my datatable returned by the method
which is the datasource, but that makes things messier)
Thanks,
Greg
| ASP.net DOCS =
http://www.aspng.com/docs
| [aspngfreeforall] member
Click here to reveal e-mail address
= YOUR ID
|
http://www.asplists.com/aspngfreeforall
= JOIN/QUIT
| news://ls.asplists.com = NEWSGROUP
Reply to this message...
Saye, Robert
cmbYourCombo.Items.Insert(0, New
ListItem
("--Choose a Supplier--"))
Robert Saye
Starent Networks
(978)851-1197
www.starentnetworks.com=20
-----Original Message-----
From: Greg Huber [mailto:
Click here to reveal e-mail address
]
Sent: Wednesday, August 07, 2002 3:13 PM
To: aspngfreeforall
Subject: [aspngfreeforall] Simple question about comboboxes
I have a combo box server control. I would like to databind it to one of =
my
methods. However, I would also like to add "Please Select" with a null =
value
to the box. What is the best way to do this?
Here is my code:
With cboStatusCode
.DataSource =3D oEstimate.GetAllEstimateStatusCode
.DataValueField =3D "ID"
.DataTextField =3D "Name"
.DataBind()
End With
If I try to add .Items.Add("Please Select") it doesn't work, unless I =
add it
after the databind which makes sense. Unfortunately, if I do that, it =
shows
up as the last item in the drop down, and I want it as the first. Is it =
not
possible to add a "Please Select" using databind if you want it to be =
the
first item in your combo box? (I realize I could do a for loop in the =
code
and use the .items.add for each item in my datatable returned by the =
method
which is the datasource, but that makes things messier)
Thanks,
Greg
| ASP.net DOCS =3D
http://www.aspng.com/docs
| [aspngfreeforall] member
Click here to reveal e-mail address
=3D YOUR ID
|
http://www.asplists.com/aspngfreeforall
=3D JOIN/QUIT
| news://ls.asplists.com =3D NEWSGROUP
Reply to this message...
System.Web.UI.WebControls.ListItem
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com