2012-07-23 55 views
0

我的列表視圖太寬。 。無論在哪裏,我把寬度標籤(使用ListView本身,在表中應該在哪裏我可以把他們我的代碼如下:?我想整個表以不超過850像素寬Listview - 不可控寬度 - 太寬

<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> 

回答

0

嘗試使用CSS(樣式=「寬度:850像素;」):

<table cellpadding="1" style="width:850px;" border="1" runat="server" id="tblProducts" > 
+0

事實並非如此。工作,它控制按鈕/文本不在列表中但是列表視圖不受更改影響。 – gbam 2012-07-23 18:20:42

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>