Formatting of Datalist in vs2005b2 asp.net2.0

liunx

Guest
I have a Datalist that contains data from a comments table. Within this Datalist I have embedded a FormView inside the footer in order to add an input form for adding new comments.

The problem I am having is that I cannot get the fields in the FormView to follow the format of the table specified within the datalist. I thought that if you embedded a control within another control that it would retain the formatting of the parent table.

Can someone take a look at my code and tell if you see anything that may be contributing to the formating issues. The Footer fields do not lign up with the columns in the datalist. The only way I could get close was to attempt to create a second table and set the widths of the FormView table as closely as possible.


<asp:DataList ID="DataList1" runat="server"
DataKeyField="ItemID"
DataSourceID="SqlDataSource3"
BorderStyle="Solid"
BorderWidth="1px"
Font-Names="Verdana"
Font-Size="Small"
Width="100%">
<HeaderTemplate>
<table width="100%" cellpadding="2" cellspacing="0" style="border:solid 1px #000000" bordercolordark="#000000" bordercolorlight="#ececec">
<tr bgcolor="#C4DF9B">
<td><b>Post date</b></td>
<td><b>Author</b></td>
<td><b>Comments</b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><asp:Label ID="post_dateLabel" runat="server" Text='<%# Eval("post_date") %>'></asp:Label><br /></td>
<td><asp:Label ID="authorLabel" runat="server" Text='<%# Eval("author") %>'></asp:Label><br /></td>
<td><asp:Label ID="commentsLabel" runat="server" Text='<%# Eval("comments") %>'></asp:Label><br /></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr bgcolor="e6e6e6">
<td><asp:Label ID="post_dateLabel" runat="server" Text='<%# Eval("post_date") %>'></asp:Label><br /></td>
<td><asp:Label ID="authorLabel" runat="server" Text='<%# Eval("author") %>'></asp:Label><br /></td>
<td><asp:Label ID="commentsLabel" runat="server" Text='<%# Eval("comments") %>'></asp:Label><br /></td>
</tr>
</AlternatingItemTemplate>

<FooterTemplate>
<tr>
<td colspan="3">
<asp:FormView ID="FormView1" runat="server"
AllowPaging="False"
DataKeyNames="ItemID"
DataSourceID="SqlDataSource3"
CellSpacing="0"
Width="100%"
DefaultMode="Insert">
<InsertItemTemplate>

<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td width="20%"><asp:TextBox ID="post_dateTextBox" runat="server" Text='<%# Bind("post_date") %>'></asp:TextBox><br /></td>
<td width="25%"><asp:TextBox ID="authorTextBox" runat="server" Text='<%# Bind("author") %>'></asp:TextBox><br /></td>
<td><asp:TextBox ID="commentsTextBox" runat="server" Width="500" TextMode="MultiLine" Rows="2" Text='<%# Bind("comments") %>'></asp:TextBox></td>
</tr>

<tr>
<td colspan="3" align="left">
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert"></asp:LinkButton>
<asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</td>
</tr>
</table>
</InsertItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="New"></asp:LinkButton>
</ItemTemplate>
<RowStyle Font-Names="Verdana" Font-Size="Small" />
<PagerStyle BackColor="NavajoWhite" />
<HeaderStyle BackColor="Transparent" />

</asp:FormView>
</td>
</tr>
</FooterTemplate>
</asp:DataList>


Thank you!!!
 
Back
Top