控制gridview的列宽,十万火急! 生成的表格太难看了标题竟然是一个汉字一行,像这样:用户籍贯北京市长安大街东怎么控制? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 打开 WRAP = true 试试 <asp:GridView ID="GridView1" runat="server" style="position: relative; left: 15px; top: 6px;" HorizontalAlign="Center"> <RowStyle Wrap="False" /> </asp:GridView> .cs文件是这样的 OdbcConnection MyOdbcconnetion = new OdbcConnection(); MyOdbcconnetion.ConnectionString = "Dsn=webdsn;uid=test;pwd=abc123"; string sqltext = "select comcode,comcname,usercode, username , startdate,oldflag,oldflagname ,re from oldpolicy where flag ='1' and comcode matches '" + comcode + "'"; sqltext = sqltext + " and inputdate between '" + startdate +"' and '" + enddate +"' and usercode matches '" + usercode ;//+"' and flag matches '" + flag + "'"; if (flag.Trim() == "全部" || flag == "*") { sqltext = sqltext + "' and oldflag matches '*'"; } else if (flag.Trim() == "非 ") { sqltext = sqltext + "' and oldflag = '0'"; } else if (flag.Trim() == "续 ") { sqltext = sqltext + "' and oldflag <> '0'"; } else { sqltext = sqltext + "' and oldflag matches '*'"; } //sqltext = "select comcode from oldpolicy where inputdate between '" + startdate +"' and '" + enddate +"'"; Label5.Text = sqltext; OdbcDataAdapter da = new OdbcDataAdapter(sqltext,MyOdbcconnetion); DataSet myds = new DataSet(); MyOdbcconnetion.Open(); da.Fill(myds,"tb_policyno"); //GridView1.BackColor = BorderStyle.Groove; GridView1.HorizontalAlign = HorizontalAlign.Center; GridView1.Caption = " 业务查询统计"; GridView1.DataSource = myds; GridView1.DataBind(); if (GridView1.Rows.Count > 0) { GridView1.HeaderRow.Cells[0].Text = "公 司 代 码"; GridView1.HeaderRow.Cells[1].Text = "名称"; GridView1.HeaderRow.Cells[2].Text = "业务员代码"; GridView1.HeaderRow.Cells[2].Width = 10 ; GridView1.HeaderRow.Cells[3].Text = "业务员姓名"; GridView1.HeaderRow.Cells[3].Width = 10 ; GridView1.HeaderRow.Cells[4].Text = "业务员姓名号"; GridView1.HeaderRow.Cells[4].Width = 10 ; GridView1.HeaderRow.Cells[5].Text = "测试"; GridView1.HeaderRow.Cells[5].Width = 10 ; GridView1.HeaderRow.Cells[6].Text = "测试其"; GridView1.HeaderRow.Cells[6].Width = 10 ; GridView1.HeaderRow.Cells[7].Text = "测试2 "; } MyOdbcconnetion.Close(); <asp:TemplateField> <HeaderTemplate>日志分类 </HeaderTemplate> <ItemTemplate><%#Eval("category") %> </ItemTemplate> <ItemStyle Width="100px" Wrap="false" HorizontalAlign="Center" CssClass="ListCellrow" /> <HeaderStyle CssClass="ListCellTitle" Wrap="false" /> </asp:TemplateField> 难道与数据库有关?我用sqlserver 就没有问题用informix就有问题郁闷阿 <!--a:link{color:#000000;text-decoration:none}a:visited{color:#000000;text-decoration:none}a:hover{color:#CC0000;text-decoration:none}body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px;}body,td,th { font-size: 12px;}把这段加上去试试,我以前也是出那差不多的问题,我一同事写的 tableLayoutPanel控件的应用 在线等 正则表达式 还有点没完善 在类中如何设置用户控件的自定义的属性 datagird的数据绑定 请帮我翻译一下 Web Service 的几个问题 ASP的简单问题 ----------------------------------------分页问题---------------------------------- C#有什么办把把声音转成文字 我已经糊涂了! 如何批量删除文件后辍名为.TZ的文件 紧急求救:给WINFORM定义一个通用样式
<RowStyle Wrap="False" />
</asp:GridView>
.cs文件是这样的
OdbcConnection MyOdbcconnetion = new OdbcConnection();
MyOdbcconnetion.ConnectionString = "Dsn=webdsn;uid=test;pwd=abc123";
string sqltext = "select comcode,comcname,usercode, username , startdate,oldflag,oldflagname ,re from oldpolicy where flag ='1' and comcode matches '" + comcode + "'";
sqltext = sqltext + " and inputdate between '" + startdate +"' and '" + enddate +"' and usercode matches '" + usercode ;//+"' and flag matches '" + flag + "'";
if (flag.Trim() == "全部" || flag == "*")
{
sqltext = sqltext + "' and oldflag matches '*'";
}
else if (flag.Trim() == "非 ")
{
sqltext = sqltext + "' and oldflag = '0'";
}
else if (flag.Trim() == "续 ")
{
sqltext = sqltext + "' and oldflag <> '0'";
}
else
{
sqltext = sqltext + "' and oldflag matches '*'";
}
//sqltext = "select comcode from oldpolicy where inputdate between '" + startdate +"' and '" + enddate +"'";
Label5.Text = sqltext;
OdbcDataAdapter da = new OdbcDataAdapter(sqltext,MyOdbcconnetion);
DataSet myds = new DataSet();
MyOdbcconnetion.Open();
da.Fill(myds,"tb_policyno");
//GridView1.BackColor = BorderStyle.Groove;
GridView1.HorizontalAlign = HorizontalAlign.Center;
GridView1.Caption = " 业务查询统计";
GridView1.DataSource = myds;
GridView1.DataBind();
if (GridView1.Rows.Count > 0)
{
GridView1.HeaderRow.Cells[0].Text = "公 司 代 码";
GridView1.HeaderRow.Cells[1].Text = "名称";
GridView1.HeaderRow.Cells[2].Text = "业务员代码";
GridView1.HeaderRow.Cells[2].Width = 10 ;
GridView1.HeaderRow.Cells[3].Text = "业务员姓名";
GridView1.HeaderRow.Cells[3].Width = 10 ;
GridView1.HeaderRow.Cells[4].Text = "业务员姓名号";
GridView1.HeaderRow.Cells[4].Width = 10 ;
GridView1.HeaderRow.Cells[5].Text = "测试";
GridView1.HeaderRow.Cells[5].Width = 10 ;
GridView1.HeaderRow.Cells[6].Text = "测试其";
GridView1.HeaderRow.Cells[6].Width = 10 ;
GridView1.HeaderRow.Cells[7].Text = "测试2 ";
}
MyOdbcconnetion.Close();
<HeaderTemplate>日志分类 </HeaderTemplate>
<ItemTemplate><%#Eval("category") %> </ItemTemplate>
<ItemStyle Width="100px" Wrap="false" HorizontalAlign="Center" CssClass="ListCellrow" />
<HeaderStyle CssClass="ListCellTitle" Wrap="false" />
</asp:TemplateField>
我用sqlserver 就没有问题
用informix就有问题
郁闷阿
a:link{color:#000000;text-decoration:none}
a:visited{color:#000000;text-decoration:none}
a:hover{color:#CC0000;text-decoration:none}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
body,td,th {
font-size: 12px;
}把这段加上去试试,我以前也是出那差不多的问题,我一同事写的