binding data with textboxes

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
 
G

Guest

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
 
G

Guest

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!
***************************
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top