Binding to a dropdown in C#

C

Carlos

Hi all,

I have the following issue:.

I've got datatable that I am intending to bind to a dropdownlist. While
debugging

I am certain that my DataTable contains 3 valid rows. However, after the
binding

statement ends, I have three row that read 'System.Data.DataRowView' instead
of the

actual data.

Can someone help? I used to do this in VB .Net no problems referencing the
items within

a row, but the same can not be done in C#.

Thanks in advance,



Carlos.



DataTable m_DataTable_GetSchools = CatalogAccess.GetSchools();


DDL_SugMainMon.DataSource = m_DataTable_GetSchools;

DDL_SugMainMon.DataBind();
 
D

David Wier

It's because you have not assigned the field names to be shown. You most
likely have run the databind on the DDL, but not assigned a field to the
DDL's DataTextField. You must do at least that, and then, if you'd like,
also assign a field to the DataValueField of the DDL

David Wier
MVP/ASPInsider
http://aspnet101.com
http://aspexpress.com
 
M

Mark Rae

DataTable m_DataTable_GetSchools = CatalogAccess.GetSchools();
DDL_SugMainMon.DataSource = m_DataTable_GetSchools;
DDL_SugMainMon.DataValueField = ""; // field from DataTable
DDL_SugMainMon.DataTextField = ""; // field from DataTable
DDL_SugMainMon.DataBind();
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top