使用div,前台代码:
<div style="overflow: auto; width: 100%">
<%--<asp:Panel ID="Panel1" ScrollBars="Auto" runat="server" HorizontalAlign="Center">--%>
<asp:GridView ID="GV_show" runat="server" AutoGenerateColumns="False" DataKeyNames="F_Code"
HorizontalAlign="Center" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None"
BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" OnRowDataBound="GV_show_RowDataBound"
OnRowEditing="GV_show_RowEditing"
OnRowCreated="GV_show_RowCreated">
后台添加OnRowCreated函数,禁止换行操作,如下:
protected void GV_show_RowCreated(object sender,

通过在div中设置样式overflow: auto和width: 100%,并在后台代码中添加GridView的OnRowCreated事件,禁止GridView表格单元格内容换行,实现了在GridView中添加横向滚动条的功能。具体做法是在OnRowCreated事件中,对每个单元格设置Wrap为false,并添加CSS样式以保持单词不换行。
最低0.47元/天 解锁文章
4831

被折叠的 条评论
为什么被折叠?



