CSS自动适应列表宽度显示内容
.Grid_Extend
{
table-layout:fixed;
}
.GridItem
{
OVERFLOW: hidden;
WHITE-SPACE: nowrap;
TEXT-OVERFLOW: ellipsis
}
<asp:datagrid id="dgUserInfo" runat="server" Width="100%" CssClass="Grid_Extend">
<asp:TemplateColumn SortExpression="Name" HeaderText="用户名称">
<ItemStyle CssClass="GridItem"></ItemStyle>
<ItemTemplate>
<asp:LinkButton ID=lbtnItem Runat=server ToolTip='<%# DataBinder.Eval(Container, "DataItem.UserName") %>' CommandName="Edit" CssClass="CommandButton">
<%# DataBinder.Eval(Container, "DataItem.UserName") %>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</asp:datagrid>
.Grid_Extend
{
table-layout:fixed;
}
.GridItem
{
OVERFLOW: hidden;
WHITE-SPACE: nowrap;
TEXT-OVERFLOW: ellipsis
}
<asp:datagrid id="dgUserInfo" runat="server" Width="100%" CssClass="Grid_Extend">
<asp:TemplateColumn SortExpression="Name" HeaderText="用户名称">
<ItemStyle CssClass="GridItem"></ItemStyle>
<ItemTemplate>
<asp:LinkButton ID=lbtnItem Runat=server ToolTip='<%# DataBinder.Eval(Container, "DataItem.UserName") %>' CommandName="Edit" CssClass="CommandButton">
<%# DataBinder.Eval(Container, "DataItem.UserName") %>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</asp:datagrid>