Customize Before Databinding

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
 
D

Davide Vernole [MVP]

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
 
P

Peter Osawa

That's the way I was doing until today, but I want to remove all strings
from code or SPs...
 
T

tribal

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
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top