Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing Data just before binding it to DropDownList Control

Status
Not open for further replies.

jetar

Programmer
Oct 16, 2003
49
0
0
US
Below is some code where I execute a query on a column and it returns all the necessary values which I then bind to a drop down list as both the text values and actual values. But right before I bind these value I need to Trim() all of them to get rid of whitespace. Does anyone know how to alter the data that is about to be bound right before i bind it?

Code:
OleDbCmd.CommandText = "SELECT DISTINCT client_id FROM CoreProcessRange"

        cConnection.Open()

        lstClientid.DataSource = OleDbCmd.ExecuteReader()
        lstClientid.DataTextField = "client_id"
        lstClientid.DataValueField = "client_id"
        lstClientid.DataBind()
 
To elaborate a little more, basically what I need to do is run trim() on every value just before it is inserted into the drop down list, which would be simple and striaghtforward if I was using a loop to cycle through each value and could just trim them as they came along.

However since I am setting the DataTextField and DataValueFields and then binding them I am not sure how to alter all of the contents before the list is populated.

I have tried doing: .DataTextField.Trim(), but this is not working and I am not completely sure what action it actually performs. Thats all, thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top