Formview: Why is my field way over there?

D

David

I want a form where I have a single record displayed with most of the
information in two columns. The left column is the name of the field. The
right column is the content. The web page is for scheduling events, so what
I want is:

Event Name: Jim's Wedding.

I created the following markup


<asp:FormView ID="FormView1" runat="server" DataKeyNames="EventID"
DataSourceID="SqlDataSource1" Width="100%">
<ItemTemplate>
<table width="100%">
<tr align="left" >
<td align="left" >Event Name:</td>
<td align="left"><asp:Label ID="EventNameLabel" runat="server"
Text='<%# Bind("EventName") %>' SkinID="LargeLabel" /></td>
</tr>
</ItemTemplate>
</asp:FormView>

Instead, what I get is:


Event Name:
Jim's Wedding


How can I tell it to put the content of the EventName Field right next to
the left hand column?

For what it's worth, the entire page has more data on it, including a text
box that I want to fill the whole width of the page. Its markup is

<tr>
<td colspan="2"><asp:TextBox ID="DescriptionLabel" runat="server"
Text='<%# Bind("Description") %>' TextMode="MultiLine"
Width="100%" Height="200px"/></td>
</tr>

At the moment, I have removed that portion from the page, but that is why
there are the Width="100%" elements in the markup.
 
G

Gregory A. Beamer

I want a form where I have a single record displayed with most of the
information in two columns. The left column is the name of the field.
The right column is the content. The web page is for scheduling
events, so what I want is:

Event Name: Jim's Wedding.

I created the following markup


<asp:FormView ID="FormView1" runat="server" DataKeyNames="EventID"
DataSourceID="SqlDataSource1" Width="100%">
<ItemTemplate>
<table width="100%">
<tr align="left" >
<td align="left" >Event Name:</td>
<td align="left"><asp:Label ID="EventNameLabel"
runat="server"
Text='<%# Bind("EventName") %>' SkinID="LargeLabel" /></td>
</tr>
</ItemTemplate>
</asp:FormView>

Instead, what I get is:


Event Name:

Jim's Wedding


How can I tell it to put the content of the EventName Field right next
to the left hand column?

For what it's worth, the entire page has more data on it, including a
text box that I want to fill the whole width of the page. Its markup
is

<tr>
<td colspan="2"><asp:TextBox ID="DescriptionLabel"
runat="server"
Text='<%# Bind("Description") %>' TextMode="MultiLine"

Width="100%" Height="200px"/></td>
</tr>

At the moment, I have removed that portion from the page, but that is
why there are the Width="100%" elements in the markup.


</tr>
</ItemTemplate>

If you are binding multiple rows, which would not a FormView, you can
play games like this (Repeater is a good example), but you still have to
close the table somewhere.

One thing I do when I end up with rendering faux pas is take the source
and paste into an HTML document and fix it. I can then take the fix back
to the ASP.NET source.

Peace and Grace,
 
T

Thomas Sun [MSFT]

Hi David,

This is Thomas Sun from MSDN managed newsgroup. I will assist you with this
case.

From your description, I understand that you used FormView control to
display single record with multiple columns, but the layout of FormView was
not well when it was rendering on browser. And you want to put a row in one
line. If I have misunderstood you, please feel free to let me know.

Based on my experience, the context width or the data size can cause such
issue. Your markup that you posted partially above looks fine. To better
understand it, could you please post the whole page here? This can help us
find the root cause. You can remove sensitive data, such as Database
connection information.

Besides, you can also set the Table's border property to 1px temporarily.
This can help you view the entire layout of FormView.

In this case, you bound data using label control with Skin. To eliminate
the possibility that this is causing problem, we can remove Skin for Label
control temporarily to see whether it works.


I look forward to receiving your test results.


--
Best Regards,
Thomas Sun

Microsoft Online Partner Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

With newsgroups, MSDN subscribers enjoy unlimited, free support as opposed
to the limited number of phone-based technical support incidents. Complex
issues or server-down situations are not recommended for the newsgroups.
Issues of this nature are best handled working with a Microsoft Support
Engineer using one of your phone-based incidents.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

I want a form where I have a single record displayed with most of the
information in two columns. The left column is the name of the field. The
right column is the content. The web page is for scheduling events, so what
I want is:

Event Name: Jim's Wedding.

I created the following markup


<asp:FormView ID="FormView1" runat="server" DataKeyNames="EventID"
DataSourceID="SqlDataSource1" Width="100%">
<ItemTemplate>
<table width="100%">
<tr align="left" >
<td align="left" >Event Name:</td>
<td align="left"><asp:Label ID="EventNameLabel" runat="server"
Text='<%# Bind("EventName") %>' SkinID="LargeLabel" /></td>
</tr>
</ItemTemplate>
</asp:FormView>

Instead, what I get is:


Event Name:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top