Listbox DataValueField

Discussion in 'ASP .Net Web Controls' started by Gerald, Jun 23, 2005.

  1. Gerald

    Gerald Guest

    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
    Gerald, Jun 23, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Parodi Development
    Replies:
    0
    Views:
    3,642
    Parodi Development
    Sep 10, 2004
  2. =?Utf-8?B?UkY=?=

    Concatenating Multiple Values for DataValueField

    =?Utf-8?B?UkY=?=, Dec 2, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    7,341
    Marina
    Dec 3, 2004
  3. =?Utf-8?B?U3VuaWwgU2FiaXI=?=

    Advantage of DataValueField

    =?Utf-8?B?U3VuaWwgU2FiaXI=?=, Feb 1, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    3,543
    Eliyahu Goldin
    Feb 1, 2005
  4. tshad
    Replies:
    3
    Views:
    4,552
    tshad
    May 10, 2005
  5. Gerald

    Listbox DataValueField

    Gerald, Jun 22, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    723
    Gerald
    Jun 22, 2005
Loading...

Share This Page