.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

dropdown list wont populate values from database

Posted By:      Posted Date: October 03, 2010    Points: 0   Category :ASP.Net

Hello everyone i need help. Ive been having this problem for almost  3 days now. dropdown list won't populate from database

Below is the code i am using:

<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="PhotoAlbum.aspx.vb" Inherits="PhotoAlbum" %>

<asp:SqlDataSource ID="categoriesDataSource" runat="server"  
<%$ ConnectionStrings:ConnectionString %>"  
    SelectCommand="SELECT [CategoryID], [Name] FROM [Categories] WHERE ([UserId] = @UserId) ORDER BY [Name]"> 
<asp:QueryStringParameter Name="UserId" QueryStringField="ID"/> 

View Complete Post

More Related Resource Links

Get list of Correlation Key Values from Database


I want to know from the the Sql database (workflow persisted) how I can get a list of the unique ids I have correlating to the workflows started.  I have no problem getting the system generated Workflow Instance Id GUIDs, however I want to display our OrderId instead.

My Info

-Using Workflow 4.0

-Workflows are getting persisted to database

-correlation handle is set to my unique Id (OrderId) in the ReceiveActivity

Populate in dropdown list control


Hello need some help on this one.  I am using ASP.NET with C# and Oracle database. I am trying to return some values from my select statement to fill my dropdown list control. I am designing this in a 3 tier architecture.  Here is my codes.  I am getting an error which states "Object reference not set to an instance of an object." I am returning the field name "NAME" to be filled in my dropdown control.  What I am doing wrong?


List.cs file code

public static string _GetClientList()


string clients = string.Empty;int SessUserID =

Dropdown List values


I have an application, that has one table which stores all the dropdown list values for the app. The problem I'm encountering, is when I set up the datasorce and configure the dropdown list, there is no apparent way to pass in a value to restrict the data relevant to the dropdown list.

 any help would be greatly appreciated.

load new page and populate the values without database



I'm creating a website of 5 pages using c# (asp.net).

How do i link 2 pages, ie., on click of a button on first page should take me to second page.

Advance thanks,


Populate list of values for runtime parameters. SQL server 2008



I have created a Trial balance report using report builder and have setup runtime filter parameters for GL description. I would like to populate  runtime filter parameter with values from the GL master table (GL00100) enableing users to select  values from the drop down list.

How  can i acheive this task? 





Dropdown list value to insert into database


I have a dripdownlist

<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="NameSource"
           DataTextField="Choice" DataValueField="Appliers" AutoPostBack="True">

I want to insert into database with the following code. I want the  Appliers instead of Choice to be inserted. Now this code insert the Choice field only. How should I modify this code ? Thanks

e.Command.Parameters("Name").Value = DropDownList1.SelectedValue

I tried SelectedItem it becomes error too... help...

Dropdown list values in C#


reply how can add data value by loop in dropdown reply me soon

Populate asp:RadioButtonList with values from database


Hi All!

I have a gridview with a RadioButtonList I need to populate. It is as such"

<asp:GridView ID="GridView1" AllowPaging="true" PageSize="7" runat="server" DataSourceID="mainDS"

DataKeyNames="id" AutoGenerateColumns="False" Width="100%" RowStyle-BackColor="LightGray"

AutoGenerateEditButton="false" AutoGenerateSelectButton="false" AlternatingRowStyle-BackColor="white"

HeaderStyle-BackColor="Black" HeaderStyle-ForeColor="white" ForeColor="black"

PagerStyle-ForeColor="#1A7A5E" EmptyDataText="No Data To Display">


<asp:BoundField HeaderText="Question" DataField="number" ItemStyle-Wrap="false" ItemStyle-VerticalAlign="Top" />

<asp:BoundField DataField="question" ItemStyle-Wrap="false" ItemStyle-VerticalAlign="Top" />

<asp:TemplateField HeaderText="Select">


<asp:Label ID="Qid" Text='<%# Eval("number") %>' runat="server" Visible="false" />

<asp:RadioButtonList ID="answer" runat="server"

wroking on datatable to fetch only distinct values of particular column to assign to dropdown list.


As I kept my fetched datatables into session and accessing it on another page there I am

wroking on datatable to fetch only distinct values of particular column to assign to dropdown list.

Auto-fill field with a dropdown list keep losing values



i have a question. i have created a form with 2 dropdown lists and 2 field. when the user choose a value in the dropdown list it auto fill the coresponding value in the field.

now i have notice when i'm busy creating the form and testing, when i preview the form i get this error:

Infopath can not open the selected form

and what i have noticed the dropdown list is not attached any more to the table i have set.

can someone tell me what the reason is that the field keep losing the attached field?

Dropdown list in ASP.NET - How to get value selected

am sure this must be very simple, but unforunately I can't figure it out.
I have the following code which populates the dropdown lists from the database. This works fine. Now, when the user selects a particular employee name from the list, I want to get the Employee Id of the selected employee. i.e. I need to get the "Eid" value. I can do this if the EId is loaded in the dropdown list, but in this case only the employee name is displayed. Please let me know howI can get the Eid value even though it is not loaded in the dropdown list.
I would really appreciate your help

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

Binding an array to dropdown list


I have the following string which is a list of urls. How do I get this to work so the url shows for the selection and also is the value?      


allLinks = newAllLinks
        Me.DropDownList1.DataTextField = "Link"
        Me.DropDownList1.DataValueField = "LinkURL"
        Me.DropDownList1.Items.Insert(0, New ListItem(" - Select - ", 0))
        Me.DropDownList1.DataSource = allLinks


 ArgumentNullException: Value cannot be null.
Parameter name: container]
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName) +121
   System.Web.UI.DataBinder.GetPropertyValue(Object container, String propName, String format) +8

Gridview with a dropdown list for editing


Hello. I am working through Scott Mitchell's ASP.Net in 24 hours book. I am finishing the photo album project.

I have a GridView that retrieves a list of uploaded photo rows for the logged-in user.
The GridView is for editing and deleting rows.

The photo Category field in the Gridview is a dropdown list. The text entry field was deleted after converting this field to a Template.

Like the uploaded photos, these Categories are user-specific. They are created in another web page.

Users also have the option to select "none" for the category when they upload an image.

For the GridView:  The Category ID field's ItemTemplate and EditItemTemplate both have a " - None - " choice added to them.

I am getting this error:

'pictureReadOnlyCategories' has a SelectedValue which is invalid because it does not exist in the list of items. Parameter name: value


Note: The ID for the ItemTemplate for that dropdown list is the ID listed above in the error: "pictureReadOnlyCategories".


Am I missing some step in this process of changing a GridViews text field to a dropdown that can be used for editing? I went through the book's instructions three times.

Here is my code for the dropdown list and a screenshot of the Design

Populating Dropdown List using FK


Hi Folks,

2 Questions. I am trying out Data Entities in VWD 2010 Express. I have a parent (Customers) and child (Orders) table. Customers table has FirstName, LastName and Email columns.

Q1. When I view/edit/insert an Order, it shows the customer's first name in dropdown list whereas I want the full name. How can this be done?

Q2. How can I change the default behavior of PK/FK relationship so that customer's Email is displayed instead of Name?

Any help will be much appreciated.


Is it possible to populate property choices from a database?


I'm creating my first server control, and have it working where I can set up an enum and the user can set a property's choices,  based off of that enum.  But I'd like it to pull records from a database and populate the list of choices for the property from a database.  This would allow me to add a new "Host System" to the database, and the other designers wouldn't have to get a new copy of the dll.



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend