binding data with textboxes

  • Thread starter Thread starter alpoor
  • Start date Start date
A

alpoor

I have lots of textboxes on my webform. I need to bind them with fields
from table. I am not sure how to bind with textboxes. I have seen so many
samples for dropdown boxes and datagrid binding, but not with textboxes

Is there any easy of doing it

Any ideas

Thanks
 
One solution could be using naming convention for textboxes like
ID="txt_[DBColumnName]"
When reading data from db you can set right value to right textbox by using
FindControl-method.
((TextBox)Page.FindControl("txt_[CurrentDBColumn]")).Text = [CurrentDBValue]

I assume that your SQL returns only one row which contains values, otherwise
you should use DataGrid, DataList or Repeater
 
Individual text boxes cannot be bound as easily as repetitive controls. You
still have the option, but you could end up with an error if you have
multiple rows and generically set to a field.

Normally, textbox binding is done behind the scenes rather than
declaratively.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Back
Top