gridview小弟我自定了列宽 但是在IE上,却是 列宽是平分的
gridview我自定了列宽 但是在IE上,却是 列宽是平分的
代码如下:
<asp:GridView ID="GridView1" runat="server" Width="5800px"
AutoGenerateColumns="False"
onselectedindexchanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:CommandField ShowSelectButton="True">
<ItemStyle Width="40px" />
</asp:CommandField>
<asp:BoundField DataField="no" HeaderText="工号">
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha01" HeaderText="姓名" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha02" HeaderText="姓别" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha03" HeaderText="部门" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha04" HeaderText="班组车间" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha06" HeaderText="学历" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha07" HeaderText="民族" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha19" HeaderText="备注" >
<ItemStyle Width="150px" />
</asp:BoundField> -------
在VS2008 上显示,列宽分布是按照width属性的,但在IE上却不是这样子了,好奇怪,我已经设了AutoGeneratecolumns属性等于false,请高人的指点指点
------解决方案--------------------
用这种形式写
<asp:TemplateField>
<HeaderTemplate>工号</HeaderTemplate>
<ItemTemplate>
<div style=" width:60px; white-space:nowrap; overflow:hidden;" ><%#eval("no")></div>
</ItemTemplate>
</asp:TemplateField>
------解决方案--------------------
你是怎么测试的啊,下面的代码在IE8,Firefox下都没有任何问题啊,看问题要看全部
代码如下:
<asp:GridView ID="GridView1" runat="server" Width="5800px"
AutoGenerateColumns="False"
onselectedindexchanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:CommandField ShowSelectButton="True">
<ItemStyle Width="40px" />
</asp:CommandField>
<asp:BoundField DataField="no" HeaderText="工号">
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha01" HeaderText="姓名" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha02" HeaderText="姓别" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha03" HeaderText="部门" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha04" HeaderText="班组车间" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha06" HeaderText="学历" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha07" HeaderText="民族" >
<ItemStyle Width="60px" />
</asp:BoundField>
<asp:BoundField DataField="ha19" HeaderText="备注" >
<ItemStyle Width="150px" />
</asp:BoundField> -------
在VS2008 上显示,列宽分布是按照width属性的,但在IE上却不是这样子了,好奇怪,我已经设了AutoGeneratecolumns属性等于false,请高人的指点指点
------解决方案--------------------
用这种形式写
<asp:TemplateField>
<HeaderTemplate>工号</HeaderTemplate>
<ItemTemplate>
<div style=" width:60px; white-space:nowrap; overflow:hidden;" ><%#eval("no")></div>
</ItemTemplate>
</asp:TemplateField>
------解决方案--------------------
你是怎么测试的啊,下面的代码在IE8,Firefox下都没有任何问题啊,看问题要看全部
- HTML code
<%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { System.Data.DataTable dt = new System.Data.DataTable(); System.Data.DataRow dr; dt.Columns.Add(new System.Data.DataColumn("no", typeof(System.Int32))); dt.Columns.Add(new System.Data.DataColumn("ha01", typeof(System.String))); dt.Columns.Add(new System.Data.DataColumn("ha02", typeof(System.Double))); dt.Columns.Add(new System.Data.DataColumn("ha03", typeof(System.String))); dt.Columns.Add(new System.Data.DataColumn("ha04", typeof(System.Double))); dt.Columns.Add(new System.Data.DataColumn("ha05", typeof(System.String))); dt.Columns.Add(new System.Data.DataColumn("ha06", typeof(System.Double))); dt.Columns.Add(new System.Data.DataColumn("ha07", typeof(System.String))); dt.Columns.Add(new System.Data.DataColumn("ha19", typeof(System.String))); System.Random rd = new System.Random(); for (int i = 0; i < 6; i++) { dr = dt.NewRow(); dr[0] = i + i; dr[1] = "【孟子E章】" + i.ToString(); dr[2] = System.Math.Ceiling(rd.NextDouble() * 1000); dr[3] = DateTime.Now.AddDays(rd.Next(100) - rd.Next(100)); dr[4] = System.Math.Ceiling(rd.NextDouble() * 1000); dr[5] = DateTime.Now.AddDays(rd.Next(100) - rd.Next(100)); dr[6] = System.Math.Ceiling(rd.NextDouble() * 1000); dr[7] = DateTime.Now.AddDays(rd.Next(100) - rd.Next(100)); dr[8] = "江西省抚州市东乡县邓家乡松湖村下园组12号"; dt.Rows.Add(dr); } GridView1.DataSource = dt; GridView1.DataBind(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form runat="server"> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"> <Columns> <asp:CommandField ShowSelectButton="True"> <ItemStyle Width="40px" /> </asp:CommandField> <asp:BoundField DataField="no" HeaderText="工号"> <ItemStyle Width="60px" /> </asp:BoundField> <asp:BoundField DataField="ha01" HeaderText="姓名"> <ItemStyle Width="60px" /> </asp:BoundField> <asp:BoundField DataField="ha02" HeaderText="姓别"> <ItemStyle Width="60px" /> </asp:BoundField> <asp:BoundField DataField="ha03" HeaderText="部门"> <ItemStyle Width="60px" /> </asp:BoundField> <asp:BoundField DataField="ha04" HeaderText="班组车间"> <ItemStyle Width="60px" /> </asp:BoundField> <asp:BoundField DataField="ha06" HeaderText="学历"> <ItemStyle Width="60px" /> </asp:BoundField> <asp:BoundField DataField="ha07" HeaderText="民族"> <ItemStyle Width="60px" /> </asp:BoundField> <asp:BoundField DataField="ha19" HeaderText="备注"> <ItemStyle Width="150px" /> </asp:BoundField> </Columns> </asp:GridView> </form> </body> </html>