473,395 Members | 2,423 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,395 software developers and data experts.

how to retrieve selected value of dropdownlist filled from datasource in asp.net

How to retrieve selected value of dropdownlist filled from datasource in asp.net?

Expand|Select|Wrap|Line Numbers
  1.         Dim str1 As String = "SELECT UserName FROM Login WHERE Category = 'Property'"
  2.         Dim cmd1 As New SqlCommand(str1, conn)
  3.         Dim myreader1 As SqlDataReader
  4.         conn.Open()
  5.  
  6.         myreader1 = cmd1.ExecuteReader()
  7.  
  8.         DDLCat.DataSource = myreader1
  9.  
  10.         DDLCat.DataValueField = "UserName"
  11.  
  12.         DDLCat.DataTextField = myreader1.ToString()
  13.  
  14.         DDLCat.DataBind()
  15.  
  16.  
  17.         conn.Close()
Dec 2 '10 #1
1 2399
DataValueField and DataTextField are distinguished incase to have different values for display and selection.

In your case both can be same since you dont expect other than the value from ddl..moreover you have not queried any other column values from database to bind against "UserName"..
Expand|Select|Wrap|Line Numbers
  1. DDLCat.DataValueField = "UserName"
  2. DDLCat.DataTextField = "UserName"
Dec 5 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: DC Gringo | last post by:
I have a dropdownlist that, upon form submission, I'd like to maintain the selected value when I get my result...how do I do that? <asp:dropdownlist Font-Size="8" id="ddlCommunities"...
0
by: Xiru | last post by:
I would like to retrieve the value from a DataList on postback. I can read the ItemIndex and values from a child TextBox but not cannot seem to find a way to read a databound item on the datalist....
6
by: Jenna Alten | last post by:
I have a datagrid with a template column that contains a dropdown list. I currently fill and display the dropdown list on the page load. This is working correctly. I am NOT using an Edit Column. I...
2
by: Antonio D'Ottavio | last post by:
Good morning, I've a problem with a dropdownlist located inside any row of a datalist, I fill both datalist and dropdownlist at runtime, the problem is with the dropdownlist infact using the event...
4
by: Chris Kettenbach | last post by:
Good morning all, I am sure this has been asked but I did not see anything. I have a datalist control. In the edititemtemplate I have a dropdownlist. I know on the itemdatabound event is where I...
0
by: Luqman | last post by:
My combobox is bound to sqldatasource, what I want is, when I change the combobox selected value, the sql datasource should be positioned to that value, so that all textboxes bound to that sql data...
0
by: saiprex | last post by:
I have DropDownList control which is binded to SqlDataSource. The SqlDataSource gets the values from TABLE, it all works great. But how can i set the selected value for the DropDownList? The table is...
3
by: eshwaramoorthy | last post by:
Hi to all, I have one gridview with checkboxes which contains values of type integer(empid) and string(name) and if i checked it, those respective values must be displayed in other gridview.pls hlp...
1
by: ashutoshjoshi10 | last post by:
Hi, I am using a Dijit.form.filteringSelect to display values using the dojox.data.QueryReadStore. But, after overriding _filterResponse() to format the data in a Dojo-parsable format, whatever...
1
by: VanZandt | last post by:
how do I get a cell value for selected qty? Please help!!! below is the code. Thanks, <?xml version = "1.0" encoding = "utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.