菜鸟提问:关于GridView的表头设置问题!! asp.net(c#)2.0 开发webform在.aspx页面上,那么设置GridView的表头,可以通过该控件属性中的Columns来设置每一列的表头请问:如果想要在.aspx.cs中动态设置每一列的表头,代码怎么写???学习,关注^^^^^^^^^^ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 试试在row_databound里判断,当row类型为header时,设置row LZ:.aspx.cs 不能设置吗???请给出具体代码????????? 可以直接设置表头为HTML代码字符串"<th><td></td></th>" 应该有colomns[index].headtext 的属性 参考下下面的代码。 protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { switch (e.Row.RowType) { case DataControlRowType.Header: //第一行表头 TableCellCollection tcHeader = e.Row.Cells; tcHeader.Clear(); tcHeader.Add(new TableHeaderCell()); tcHeader[0].Attributes.Add("rowspan", "3"); //跨Row tcHeader[0].Attributes.Add("bgcolor", "white"); tcHeader[0].Text = ""; tcHeader.Add(new TableHeaderCell()); //tcHeader[1].Attributes.Add("bgcolor", "Red"); tcHeader[1].Attributes.Add("colspan", "6"); //跨Column tcHeader[1].Text = "全部信息</th></tr><tr>"; }} GridView控件实现CSS固定表头http://www.aspx58.com.cn/Default_AC_View.aspx?ID=103 同时使用前置和后置代码不可以吗? js操作SQL报出警告 找工作,散发, 深圳 页面分辨率问题 !!!->请教各位大哥,怎么判断UpdatePanel有没有更新完,小弟很急.谢谢 关于存储过程的一个问题! 视频点播的问题。大伙进来看看。播放不连续的问题 新建ASP.netweb应用程序时出错,提示web服务器运行的不是ASP.net1.1 很急,大家都帮我看看吧,sql语句语法错误,偶就这点分了,在线等待 请叫各位大虾,在.aspx中如何调用javascript,不胜感激! 附加数据库的作用?不附加行不行? 抓狂了,怎么老是没有权限访问文件.....查了很多资料,解决不了?????
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
switch (e.Row.RowType)
{
case DataControlRowType.Header:
//第一行表头
TableCellCollection tcHeader = e.Row.Cells;
tcHeader.Clear();
tcHeader.Add(new TableHeaderCell());
tcHeader[0].Attributes.Add("rowspan", "3"); //跨Row
tcHeader[0].Attributes.Add("bgcolor", "white");
tcHeader[0].Text = "";
tcHeader.Add(new TableHeaderCell());
//tcHeader[1].Attributes.Add("bgcolor", "Red");
tcHeader[1].Attributes.Add("colspan", "6"); //跨Column
tcHeader[1].Text = "全部信息</th></tr><tr>";
}
}