Parag’s Den

Dedicated to my adored friends…..

Asp.Net (Populating DropDownList – The key aspect that needs to be noted)

Posted by paragdongre on November 6, 2007


Some times you may notice that, you are getting the following values in your dropdownlists.

<option value=”System.Data.DataRowView”>System.Data.DataRowView</option>

When binding to the DropDownList (and some of the other controls), you need to specify the DataTextField and DataValueField (if you don’t specify the DataValueField then the control will automagically use what you specified for the DataTextField).

Something like this….

DropDownList1.DataTextField = “FieldNameThatIsToBeDisplayedForEachItem”
DropDownList1.DataValueField = “FieldNameThatRepresentsTheValueOfTheItem”

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: