Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binding two database fields to one label?

Status
Not open for further replies.

rollout369

Programmer
Aug 20, 2003
31
US
I'm very new to visual studio (first day) and I've run into my first problem. I've created a form and have bound some textboxes and labels to database fields. What I want to do is to bind the "firstname" and "lastname" database fields to one label. My motive to do this is so that the name appears on one line and resizes according to its length. Can I bind two fields to one label? If not, how can I show two fields right next to each other on a form and keep them from overlapping? Thanks for your help

=========================
rollout
=========================
 
to get 2 fields in 1 label, you have 2 options:

1:


<asp:label id=&quot;lblName&quot; runat=&quot;server&quot;><%# container.dataitem(&quot;FName&quot;) %>    <%# container.dataitem(&quot;LName&quot;)%></asp:label>


or you can do it in your sql statement like this:

Select FirstName + ' ' + LastName as YourName from MyTable;


<asp:label id=&quot;lblName&quot; runat=&quot;server&quot;><%# container.dataitem(&quot;YourName&quot;) %></asp:label>
 
Thanks, but if I'm not mistaken that's how I would do it in a web page. What about within a vb.net program?

=========================
rollout
=========================
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top