Listbox DataValueField

G

Gerald

Hi,

Is it possible to do some action on the value that will be the
DataValueField of a listbox?

I have a listbox with a list of item. But I would like to encode the value
ID that the client will see in the html.
There is no way to do that on the database, it has to be done on the .net
side.

For instance:

I have
SearchID.DataSource = oReader;
SearchID.DataValueField = "Value";
SearchID.DataTextField = "Text";
SearchID.DataBind ();

And I would like to have something like:

SearchID.DataSource = oReader;
SearchID.DataValueField = EncodeID("Value");
SearchID.DataTextField = "Text";
SearchID.DataBind();

EncodeID being whatever you want, just a simple function.

I dont want to loop through anything and would like if possible to keep the
databinding stuff.

Another option would be to response.write the listitem, but again, I want to
keep the four lines there and apply a function to it.

Thanks for your help.

Gerald
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top