Solved

Formatting the Formview Control in Visual Web Developer

Posted on 2008-06-21
2
236 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Using Quotation Marks in PHP This question (http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28217211.html) seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

929 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

10 Experts available now in Live!

Get 1:1 Help Now