Is this bad asp.net design for populating a form?

N

needin4mation

I have a database with values. I retrieve the data from that database.

I want to display that data from the database on the webpage.

Is it incorrect to take that data and assign it manually like:

(assuming I have textboxes named like this)

txtLastName.Text = MyDataReader.Item("MyDatabaseColumn");

or, am I supposed to do it in a grid or some other control like this:

<ItemTemplate>
<asp:TextBox id="lbl_employer" runat="server" Width="200" text='<%#
DataBinder.Eval(Container.DataItem, "employer") %>'>
</asp:TextBox>
</ItemTemplate>

The former seems just like I did in Classic ASP, so it makes me think
it is "wrong." These textboxes are populated and then the user can
update, etc. from the form. This form doubles as dataentry for new
records also. I was just reusing everything. Does it matter?
Improper design?

Thank you for advice.
 
C

Curt_C [MVP]

I have a database with values. I retrieve the data from that database.

I want to display that data from the database on the webpage.

Is it incorrect to take that data and assign it manually like:

(assuming I have textboxes named like this)

txtLastName.Text = MyDataReader.Item("MyDatabaseColumn");

or, am I supposed to do it in a grid or some other control like this:

<ItemTemplate>
<asp:TextBox id="lbl_employer" runat="server" Width="200" text='<%#
DataBinder.Eval(Container.DataItem, "employer") %>'>
</asp:TextBox>
</ItemTemplate>

The former seems just like I did in Classic ASP, so it makes me think
it is "wrong." These textboxes are populated and then the user can
update, etc. from the form. This form doubles as dataentry for new
records also. I was just reusing everything. Does it matter?
Improper design?

Thank you for advice.

What you propose, if I understood right, is fine. No need to stick it in
a grid if you only need a textbox....
 

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

Members online

Forum statistics

Threads
474,434
Messages
2,571,685
Members
48,796
Latest member
Greg L.

Latest Threads

Top