我的列表视图太宽了。无论我在哪里放置宽度标签(使用Listview本身,在表格中。我应该把它们放在哪里?我的代码如下:我希望整个表格不超过850像素宽。
<asp:ListView ID="ListView1" runat="server" EnableViewState = "true" Visible="true" wra>
<LayoutTemplate>
<table cellpadding="1" width="850px" border="1" runat="server" id="tblProducts" >
<tr id="Tr1" runat="server">
<th id="Th1" runat="server">
Field Name
</th>
<th id="Th2" runat="server">
Type
</th>
<th id="Th3" runat="server">
XML Path
</th>
<th id="Th4" runat="server">
Vendor Path
</th>
<th id="Th5" runat="server">
Status
</th>
<th id="Th6" runat="server">
Comments
</th>
<th id="Th7" runat="server">
Edit
</th>
<th id="Th8" runat="server">
Forms
</th>
<th id="Th9" runat="server">
CU Specific
</th>
</tr>
<tr runat="server" id="itemPlaceholder" />
</table>
<asp:DataPager runat="server" ID="DataPager1" PageSize="50">
<Fields>
<asp:NumericPagerField ButtonCount="10" CurrentPageLabelCssClass="CurrentPage" NumericButtonCssClass="PageNumbers"
NextPreviousButtonCssClass="PageNumbers" NextPageText=" Next " PreviousPageText=" Previous " />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr id="Tr2" runat="server">
<td>
<asp:Label ID="FieldName" runat="Server" Text='<%#Eval("FLD_NM") %>'/>
</td>
<td>
<asp:Label ID="Type" runat="Server" Text='<%#Eval("DATA_TYPE_CD") %>' />
</td>
<td>
<asp:Label ID="XMLPath" runat="Server" Text='<%#Eval("WS_XML_PATH_TX") %>' />
</td>
<td>
<asp:Label ID="VendorPath" runat="Server" Text='<%#Eval("FLD_NM") %>' />
</td>
<td>
<asp:DropDownList ID="Status" runat="Server" />
</td>
<td>
<asp:TextBox ID="Comments" runat="Server" MaxLength="100" />
</td>
<td>
<asp:LinkButton ID="EditButton" runat="Server" Text="Edit" CommandName="Edit" />
</td>
<td>
<asp:Label ID="Forms" runat="Server" Text='<%#Eval("FLD_NM") %>' />
</td>
<td>
<asp:Label ID="CUSpecific" runat="Server" Text='<%#Eval("FLD_NM") %>' />
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<tr style="background-color: #ADD8E6">
<td>
<asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:LinkButton ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="FieldName" runat="server" Text='<%# Bind("FLD_NM") %>' MaxLength="50" /><br />
</td>
<td>
<asp:TextBox ID="DataType" runat="server" Text='<%# Bind("DATA_TYPE_CD") %>' MaxLength="50" /><br />
</td>
</tr>
</EditItemTemplate>
</asp:ListView>
答案 0 :(得分:0)
尝试使用css(style =“width:850px;”):
<table cellpadding="1" style="width:850px;" border="1" runat="server" id="tblProducts" >
答案 1 :(得分:0)
只需使用下面提供的<LayoutTemplate>
进行更改,我希望它能解决您的问题。
<layouttemplate>
<table id="tblProducts" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table id="itemPlaceholderContainer" runat="server" style="width: 850px;">
<tr id="Tr2" runat="server">
<th id="Th1" runat="server">Field Name</th>
<th id="Th2" runat="server">Type</th>
<th id="Th3" runat="server">XML Path</th>
<th id="Th4" runat="server">Vendor Path</th>
<th id="Th5" runat="server">Status</th>
<th id="Th6" runat="server">Comments</th>
<th id="Th7" runat="server">Edit</th>
<th id="Th8" runat="server">Forms</th>
<th id="Th9" runat="server">CU Specific</th>
</tr>
<tr id="itemPlaceholder" runat="server"></tr>
</table>
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td2" runat="server" style="">
<asp:DataPager runat="server" ID="DataPager1" PageSize="50">
<Fields>
<asp:NumericPagerField ButtonCount="10" CurrentPageLabelCssClass="CurrentPage" NumericButtonCssClass="PageNumbers"
NextPreviousButtonCssClass="PageNumbers" NextPageText=" Next " PreviousPageText=" Previous " />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</layouttemplate>