Solved

Formatting the Formview Control in Visual Web Developer

Posted on 2008-06-21
2
224 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
Comment Utility
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
Comment Utility
THANK YOU
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Developer tools in browsers have been around for a while, yet they are still heavily underused by developers. Developers still fix html or CSS then refresh page to see effect, or they put alert or debugger in JavaScript and then try again and again …
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

762 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

9 Experts available now in Live!

Get 1:1 Help Now