0

我的列表视图太宽了。无论我将宽度标签放在哪里(使用 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" />&nbsp;
                            <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>
4

2 回答 2

0

尝试使用 css (style="width:850px;"):

<table cellpadding="1" style="width:850px;" border="1" runat="server" id="tblProducts" >
于 2012-07-23T16:51:17.950 回答
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>
于 2013-01-25T11:20:18.717 回答