473,385 Members | 1,392 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.

DropDownList.SelectedValue not working

Hello. I have the following code on an ASP webform that formats a
dropdownlist named ddlCustomer...

'Populate ddlCustomer
Dim CustAdapter As New SqlDataAdapter("SELECT * FROM
lkup_Customers", SqlConnection1)
Dim CustDataset As New DataSet
CustAdapter.Fill(CustDataset, "lkup_Customers")
Me.ddlCustomer.DataMember = "lkup_Customers"
Me.ddlCustomer.DataSource = CustDataset
Me.ddlCustomer.DataTextField = "CompanyName"
Me.ddlCustomer.DataValueField = "CustomerID"
Me.ddlCustomer.DataBind()
Me.ddlCustomer.Items.Insert(0, New ListItem("", "")) 'Create Default
Blank Row
My problem is that when I use the syntax ddlCustomer.SelectedValue to try
and retrieve the user-selected value, the value is always "" (null). What
can I do to retrieve the selectedvalue? Thanks.
Jul 21 '05 #1
3 7940
try request("ddlcustomer")

"MrMike" wrote:
Hello. I have the following code on an ASP webform that formats a
dropdownlist named ddlCustomer...

'Populate ddlCustomer
Dim CustAdapter As New SqlDataAdapter("SELECT * FROM
lkup_Customers", SqlConnection1)
Dim CustDataset As New DataSet
CustAdapter.Fill(CustDataset, "lkup_Customers")
Me.ddlCustomer.DataMember = "lkup_Customers"
Me.ddlCustomer.DataSource = CustDataset
Me.ddlCustomer.DataTextField = "CompanyName"
Me.ddlCustomer.DataValueField = "CustomerID"
Me.ddlCustomer.DataBind()
Me.ddlCustomer.Items.Insert(0, New ListItem("", "")) 'Create Default
Blank Row
My problem is that when I use the syntax ddlCustomer.SelectedValue to try
and retrieve the user-selected value, the value is always "" (null). What
can I do to retrieve the selectedvalue? Thanks.

Jul 21 '05 #2
When are you calling the propulate ddlcustomer in pageload? If so are you
doing an if not ispostback then
"Populate customer
endif

reason i ask is if your calling it in pageload and doing it without the
command above it's refreshing the grid before you retrieve the value.
"MrMike" wrote:
Hello. I have the following code on an ASP webform that formats a
dropdownlist named ddlCustomer...

'Populate ddlCustomer
Dim CustAdapter As New SqlDataAdapter("SELECT * FROM
lkup_Customers", SqlConnection1)
Dim CustDataset As New DataSet
CustAdapter.Fill(CustDataset, "lkup_Customers")
Me.ddlCustomer.DataMember = "lkup_Customers"
Me.ddlCustomer.DataSource = CustDataset
Me.ddlCustomer.DataTextField = "CompanyName"
Me.ddlCustomer.DataValueField = "CustomerID"
Me.ddlCustomer.DataBind()
Me.ddlCustomer.Items.Insert(0, New ListItem("", "")) 'Create Default
Blank Row
My problem is that when I use the syntax ddlCustomer.SelectedValue to try
and retrieve the user-selected value, the value is always "" (null). What
can I do to retrieve the selectedvalue? Thanks.

Jul 21 '05 #3
Andrew, You're correct, I need to check for postback. Thank you very much!

"Andrew Alger" wrote:
When are you calling the propulate ddlcustomer in pageload? If so are you
doing an if not ispostback then
"Populate customer
endif

reason i ask is if your calling it in pageload and doing it without the
command above it's refreshing the grid before you retrieve the value.
"MrMike" wrote:
Hello. I have the following code on an ASP webform that formats a
dropdownlist named ddlCustomer...

'Populate ddlCustomer
Dim CustAdapter As New SqlDataAdapter("SELECT * FROM
lkup_Customers", SqlConnection1)
Dim CustDataset As New DataSet
CustAdapter.Fill(CustDataset, "lkup_Customers")
Me.ddlCustomer.DataMember = "lkup_Customers"
Me.ddlCustomer.DataSource = CustDataset
Me.ddlCustomer.DataTextField = "CompanyName"
Me.ddlCustomer.DataValueField = "CustomerID"
Me.ddlCustomer.DataBind()
Me.ddlCustomer.Items.Insert(0, New ListItem("", "")) 'Create Default
Blank Row
My problem is that when I use the syntax ddlCustomer.SelectedValue to try
and retrieve the user-selected value, the value is always "" (null). What
can I do to retrieve the selectedvalue? Thanks.

Jul 21 '05 #4

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

Similar topics

2
by: Benedict Teoh | last post by:
I created a dropdownlist containing day, month and year field and expose a property to assign a date. When I call from a aspx page and assign the value, the new date is not displayed until a submit...
3
by: sling blade | last post by:
Hi, I have a dropdownlist in my DataList control and I am trying to set the SelectedItem property of the dropdownlist so when the datalist displays the user will see the text in the dropdownlist...
0
by: Daniel Doyle | last post by:
Hello and apologies in advance for the amount of code in this post. I've also sent this message to the Sharepoint group, but thought that ASP.NET developers may also be able to help, even though...
1
by: jimb | last post by:
I can get the dropdownlist into the datagrid, and I can populate it, but I can't read it. Anybody have a working example of a dropdownlist in an editable grid? Thanks. -- .....
1
by: mitchman10 | last post by:
My Time table has TimeID,Employee,PayPeriod,ChargeCodeID,Hours My Chargecode table has ChargecodeID,c_Text I need an Editable datagrid that will show the TimeID,Employee,PayPeriod,C_Text in a...
1
by: 47computers | last post by:
Hello. I'm having a bit of difficulty with some DropDownList controls within templates in a DetailsView on my web form. Basically, I have a form where a user is building a "location profile" with...
0
by: 47computers | last post by:
Hello. I'm having a bit of difficulty with some DropDownList controls within templates in a DetailsView on my web form. Basically, I have a form where a user is building a "location profile" with...
2
by: sree reddy | last post by:
..cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls;
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
1
by: Brett | last post by:
I have a DropDownList in an ASP.NET web form that is populated with items from a lookup table by binding that DropDownList to a SqlDataSource. However, the items in the lookup table can change over...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.