Solved

Formatting the Formview Control in Visual Web Developer

Posted on 2008-06-21
2
248 Views
Last Modified: 2013-11-26
I am very new to creating web pages in Visual Web Developer and I need help formatting the FormView control.  When I bind my database to the form everything is lined up on the left side (labels and data) making it very unappealing.  I would like it to be displayed in a table format, but I can't figure out how to do it.  I know I can use the GridView control, but in this circumstance I need to use the FormView.  

Currently it looks something like:

Name: John Smith
Date of Birth: April 1, 2007
Sex: Male

I would like it to display the data like:

Name:                   John Smith
Date of Birth:        April 1, 2007
Sex:                      Male

Thanks for your hlep.
0
Comment
Question by:toddpotter
2 Comments
 
LVL 6

Accepted Solution

by:
kennethfine earned 500 total points
ID: 21839470
Hi Todd, this should be very easy. The FormView accepts an "ItemTemplate" and you can define an HTML table in that template like this:

<asp:FormView ID="FormView1"
  DataSourceID="SqlDataSource1"
  DataKeyNames="ProductID"    
  RunAt="server">
                                   
  <ItemTemplate>
    <table>
      <tr><td align="right"><b>Product ID:</b></td>       <td><%# Eval("ProductID") %></td></tr>
      <tr><td align="right"><b>Product Name:</b></td>     <td><%# Eval("ProductName") %></td></tr>
      <tr><td align="right"><b>Category ID:</b></td>      <td><%# Eval("CategoryID") %></td></tr>
      <tr><td align="right"><b>Quantity Per Unit:</b></td><td><%# Eval("QuantityPerUnit") %></td></tr>
      <tr><td align="right"><b>Unit Price:</b></td>       <td><%# Eval("UnitPrice") %></td></tr>
    </table>                
  </ItemTemplate>                  
</asp:FormView>

Here's a whole article on MSDN that discusses how to implement FormView templates.
http://msdn.microsoft.com/en-us/library/ms227423(VS.80).aspx

Hope that helps!

0
 

Author Closing Comment

by:toddpotter
ID: 31469483
THANK YOU
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now