Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Binding to a dropdown in C#

Reply
Thread Tools

Binding to a dropdown in C#

 
 
Carlos
Guest
Posts: n/a
 
      12-24-2006
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();


 
Reply With Quote
 
 
 
 
David Wier
Guest
Posts: n/a
 
      12-24-2006
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

"Carlos" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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();
>
>



 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      12-25-2006
"Carlos" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...

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();


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
1 Gridview. Dropdown A is column from database, Dropdown B is column from database, Data in A and B must be from same row. anonymoushamster@gmail.com ASP .Net 2 11-07-2007 12:40 PM
ajax cascading dropdown: second dropdown disabled acadam ASP .Net 0 12-27-2006 10:59 AM
bind a dropdown in a column in a datagrid based on the dropdown value selected in another column of the datagrid. vishnu ASP .Net 1 03-25-2006 01:24 PM
Select dropdown box bleeds into Javascript dropdown menu Mike HTML 1 12-18-2003 09:49 PM
Edit Mode - How do I populate dropdown in edittemplate from dropdown in another column? Steve Myers ASP .Net Datagrid Control 2 11-20-2003 01:09 PM



Advertisments