[ASPX/VB] inserting text into textbox

Soldato
Joined
1 Feb 2006
Posts
8,188
hi, having problems here with trying to take text from a gridview cell and paste it into another textbox on the page... the code is this:

Code:
If cb IsNot Nothing AndAlso cb.Checked Then

          ' Get the cell(5) value for the selected row
          Dim cellValue As String = row.Cells(5).Text

           ' Copy text into textbox.
            txtImageMatch.Text = cellValue
End If

This code puts the text from the cell into the textbox ok but when I hit a button to carry out an operation of the textbox then the regular expression validator kicks off saying 'please enter text only'. My RegEx is correct so that isn't the problem. Am I just pasting the text into the textbox as the wrong format or something? Very weird
 
what's the operation you're trying to carry out on the text from the textbox?
looks/sounds like this is where your validation error is coming rather than changing the field in the textbox
 
the operation on the button is to filter certain cells in the gridview based on textbox entry. I am certain it is nothing to do with that part of it though. For example, if i click a checkbox in the gridview that will automatically set the cell5 value in my textbox. When I click the button it gives regex error. If i delete the pasted in value and retype it exactly it works fine! It seems like when the values are being copied from gridview and pasted to textbox that it doesn't like the format. I can't work it out at all!
 
try the regex against the cellvalue string to confirm that it's valid.

' Get the cell(5) value for the selected row
Dim cellValue As String = row.Cells(5).Text

it sounds like that hidden characters are being carried or blank spaces.
 
try the regex against the cellvalue string to confirm that it's valid.



it sounds like that hidden characters are being carried or blank spaces.

hi, my regex allows spaces so that shouldn't be a problem... there must be something going on behind the scenes as i am sure the code is correct and it does copy the content ok but i cant work out how to avoid these problems!
 
Right how are you getting the row from the grid?
Are you using a it from within a gridview event? If so which one?
Otherwise what event are you using?
Have you tryed rebinding the grid after reassigning the data?
 
hi, just got it sorted.. it was adding extra whitespace to my textbox so adding a Trim() to get the cellvalue did the trick. Can't believe I missed that first time round
 
Back
Top Bottom