1、 以下的前台自定义表头:
<asp:BoundField DataField="档案编号" HeaderText="档案编号" ControlStyle-Width="10px" />
<asp:BoundField DataField="姓名" HeaderText="姓名" />
<asp:BoundField DataField="性别码" HeaderText="性别" />
<asp:BoundField DataField="出生日期" HeaderText="出生日期" />
<asp:BoundField DataField="民族代码" HeaderText="民族" />
2、因为GridView在没有数据时是不能显示表头的所以我在后台添加了一个空行如下:
DataTable dt = new DataTable();
dt.Columns.Add("档案编号");
dt.Columns.Add("姓名");
dt.Columns.Add("性别码");
dt.Columns.Add("出生日期");
dt.Columns.Add("民族代码");
if (dt.Rows.Count == 0)
{ dt.Rows.Add(dt.NewRow()); }
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
int columnCount = dt.Columns.Count;
GridView1.Rows[0].Cells.Clear();
GridView1.Rows[0].Cells.Add(new TableCell());
GridView1.Rows[0].Cells[0].ColumnSpan = columnCount;
GridView1.Rows[0].Cells[0].Text = "请选择所要查询的村小组";
GridView1.Rows[0].Cells[0].Style.Add("text-align", "center");我打开页面时我用JS固定了表头,让GridView在滚动时表头固定
但当我点击查询时内容能显示出来后,可固定的表头和GridView的内容不能对齐。
不知道是那出了问题。
<asp:BoundField DataField="档案编号" HeaderText="档案编号" ControlStyle-Width="10px" />
<asp:BoundField DataField="姓名" HeaderText="姓名" />
<asp:BoundField DataField="性别码" HeaderText="性别" />
<asp:BoundField DataField="出生日期" HeaderText="出生日期" />
<asp:BoundField DataField="民族代码" HeaderText="民族" />
2、因为GridView在没有数据时是不能显示表头的所以我在后台添加了一个空行如下:
DataTable dt = new DataTable();
dt.Columns.Add("档案编号");
dt.Columns.Add("姓名");
dt.Columns.Add("性别码");
dt.Columns.Add("出生日期");
dt.Columns.Add("民族代码");
if (dt.Rows.Count == 0)
{ dt.Rows.Add(dt.NewRow()); }
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
int columnCount = dt.Columns.Count;
GridView1.Rows[0].Cells.Clear();
GridView1.Rows[0].Cells.Add(new TableCell());
GridView1.Rows[0].Cells[0].ColumnSpan = columnCount;
GridView1.Rows[0].Cells[0].Text = "请选择所要查询的村小组";
GridView1.Rows[0].Cells[0].Style.Add("text-align", "center");我打开页面时我用JS固定了表头,让GridView在滚动时表头固定
但当我点击查询时内容能显示出来后,可固定的表头和GridView的内容不能对齐。
不知道是那出了问题。
解决方案 »
- 只能获取 fixed 语句初始值设定项内的未固定表达式的地址
- 下面的语句是什么意思啊 不懂!!!
- SQL语句. 重复ID且带条件过滤查询
- gridview的问题,字段换行
- 再发:image 控件图片导出到word
- (急)求水晶报表的表头与表体的打印格式?
- 求HttpModule做管理权限的文章或代码
- 请教高手一个问题
- 求教:DetailsView数据显示问题
- datagrid集锦中有个对每列统计的技巧,但只能对datagrid(多页)中显示的当前页的记录统计,而不能对datagrid所有记录统计,怎样实现呢?
- aps.net cookies问题,
- ASP.NET 使用 Lucene.net 的经典例子
EmptyDataRowStyle-HorizontalAlign="center" <EmptyDataTemplate>
<td nowrap align="center">标题 </td>
</EmptyDataTemplate>