c# - 更改 ListView 中列的宽度(c#)
问题描述
我是 ListView 的新手,我试图改变列的宽度(表格很大)。似乎更改表格中的样式标签不起作用。我可以做些什么来减小表格大小以完全适合屏幕?
<LayoutTemplate>
<table runat="server" id="table1" cellpadding="2" style="width:500px">
<tr id="tr1" runat="server" style="Background:yellow" >
<th id="th1" runat="server" style="Color:Blue"><asp:LinkButton id="link1" OnClick="link1_Click"
runat="server" style="Color:Blue">a</asp:LinkButton></th>
<th id="th2" runat="server" style="Color:Blue">b</th>
<th id="th3" runat="server" style="Color:Blue">c</th>
<th id="th4" runat="server" style="Color:Blue"> <asp:LinkButton id="link2" OnClick="link2_Click"
runat="server" style="Color:Blue"> d</asp:LinkButton> </th>
<th id="th5" runat="server" style="Color:Blue">e</th>
<th id="th6" runat="server" style="Color:Blue"> <asp:LinkButton id="link3" OnClick="link3_Click"
runat="server" style="Color:Blue">f</asp:LinkButton> </th>
<th id="th7" runat="server" style="Color:Blue">Edit</th>
<th id="th8" runat="server" style="Color:Blue">Delete</th>
</tr>
<tr runat="server" id="itemPlaceholder" />
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="tr2" runat="server" style="background:#D9D8E0">
<td> <asp:Label ID="Label1" runat="Server" Text='<%#Eval("flda") %>' /></td>
<td> <asp:Label ID="Label2" runat="Server" Text='<%#Eval("fldb") %>' /></td>
<td> <asp:Label ID="Label3" runat="Server" Text='<%#Eval("fldc") %>' /></td>
<td> <asp:Label ID="Label4" runat="Server" Text='<%#Eval("fldd") %>' /></td>
<td> <asp:Label ID="Label5" runat="Server" Text='<%#Eval("flde") %>' /></td>
<td> <asp:Label ID="Label6" runat="Server" Text='<%#Eval("fldf") %>' /></td>
<td> <asp:Button ID="button1" runat="Server" Text="Edit" CommandName="edit" /> </td>
<td> <asp:Button ID="button2" runat="Server" Text="Delete" CommandName="Delete" /></td>
</tr>
</ItemTemplate>
解决方案
而不是在样式属性中传递宽度。
<table runat="server" id="table1" cellpadding="2" style="width:500px">
尝试添加宽度属性,如下所示。
<table cellpadding="2" width="500px" border="1" runat="server" id="table1">
推荐阅读
- python - 要在列表中列出的 Python 字符串
- javascript - 身份验证失败,原因是:缺少自定义请求令牌 cookie
- reactjs - React-Final-Form 如何将道具 location.search 传递给函数
- ios - 从库中挑选的视频未在 iOS 13 中播放
- oracle - 使用 DBMS_CRYPTO 函数解密 CLOB 数据时出错
- python - 我想在数据框中找到一个特定的字符串,在找到该字符串后,我想从数据框中排除该特定行
- python - asserTrue() 封装后总是失败
- azure-api-management - 如何在 Azure API 管理中将字符串列表作为查询参数传递?
- javascript - 将使用 javascript 创建的 JSON.stringify 提交到 PHP 中的页面
- r - R : 查找第 n 个重复项