DropDownList and LINQ

J

James Page

Hi all

A simple problem: I have an aspx page with a details view on it.
The page is designed to collect the users selections and add those
selections to a SQL database.

In the details view there are two drop down lists a text box and a button
which fires the Insert method.

The first DDL is populated via a LINQ datasource on the aspx page.

The second is populated on page load:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Dim db As New MyDatabaseDataContext
Dim dropdown As DropDownList =
CType(DetailsView1.FindControl("ddlProduct"), DropDownList)
dropdown.DataSource = db.StoredProcedure2
dropdown.DataValueField = "productId"
dropdown.DataTextField = "concatName"
dropdown.DataBind()

End Sub

Everything displays and works fine.

However when the record is inserted into the database the selected value
from the second DDL is not being inserted into the database.

Am I missing something fundamental here?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top