Replace String Function in Databound TextBox

Discussion in 'ASP.NET 2.0' started by davidseye, Nov 13, 2005.

  1. I'm using a Formview control. In the item template the labels bind to data fields from the sql data source control. In the edit template(in textboxes)the line breaks in the text render, but in the item template the line breaks do not render. In classic ASP I always did a string replace function and replace "" for the line breaks (chr(13)). I can't seem to figure out how to do a replace when the string is bound to the control. Any suggestions? I appreciate the help.
     
  2. The first thing that comes to mind is trying to do it without making it databound. I know Microsoft is moving more to a point and click programming concept but I really have a hard time accepting it.

    My thoughts on it is if you can avoid databinding (assuming it will not create a extremely large workload) you should. I always try to bring in the data, process it, and filter the junk out before I set it to a control (in code). I know that most people say you should not have to worry about the data if it is properly entered into the database, but I have always run with the mindset that never trust what you are getting is what you need.

    So in short I know I am not giving you the perfect answer but I would not databind a textbox. Just keep it unbound and append the data to it though a <txtName>.text = <value> manner OnLoad that way you can apply your logic to the data before it even makes it to the control.
     

Share This Page