Is it possible to bind a datarow to the value of a DDL?

R

RSH

Hi,

i have a situation where I have an object (Company) that returns a dataset
for the Employees Property which in turn I would like to bind to a DDL.

My problem is that I want to be able to select the Employee from the DDL and
return the detail information for the selected employee
onSelectIndexChanged. I was thinking since I alredy have the information in
the Object I would like to bind the datarow to the value and onchange I
would simply extract the information and display it.

I have been struggling with the syntax:

company1 = New Company("00000001")


DropDownList1.DataSource = company1.Employees

DropDownList1.DataTextField = company1
..Employees.Tables(0).Columns(3).ColumnName 'This binds the
Employee's name

DropDownList1.DataValueField = datarow() 'This is where I would
like to bind the DataRow

DropDownList1.DataBind()







Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object,
ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged

Label1.Text = ???? ' This is where I would like to access the
DataRows Values

End Sub



How do i go about doing this? Is it a good idea??

Thanks,

Ron
 
G

Guest

It would be more efficient if you store Employee ID(s)
in your dropdown list as a value and then on
DropDownList1_SelectedIndexChanged event get Employee single row from the
database based on dropdown selected value.

Storing large datasets in memory can be expensive and can affect your
performance.

Hope it helps
 

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

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top