Solved

Formatting the Formview Control in Visual Web Developer

Posted on 2008-06-21
2
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…

730 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