Customize Before Databinding

  • Thread starter Thread starter Peter Osawa
  • Start date Start date
P

Peter Osawa

Hi,

I'm filling a DropDownList with a database data with Databind.

The list is a lot of languages, and I would like to add a string before
each field.

If I do ddlLanguages.DataTextField = "MyString" + "DB_FIELD"; I get an
error, normal...

How do I add what I want before or after de databse info ?

TIA
 
Peter Osawa said:
Hi,
I'm filling a DropDownList with a database data with Databind.
The list is a lot of languages, and I would like to add a string
before each field.
If I do ddlLanguages.DataTextField = "MyString" + "DB_FIELD"; I get an
error, normal...
How do I add what I want before or after de databse info ?

You can do this in the SELECT, directly in your stored procedure o SQL
statement. Like this:

SELECT 'MyString' + DB_FIELD AS LanguageField FROM DB_TABLE
 
That's the way I was doing until today, but I want to remove all strings
from code or SPs...
 
Peter,

why not have a custom collection class, fill it up with
data from the database and bind the dropdownlist with an
object of this class

You can manipulate the properties in the class once
filled up
 
Back
Top