gridview具有相同的标题名称? [英] gridview with same header name?

查看:83
本文介绍了gridview具有相同的标题名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,我在运行时使用未知列数创建了一个gridview。基本上2列重复一次以上。我的gridview标题显示如下: -





[SNo] [RoomNo] [SNo1] [RoomNo1] [SNo2] [RoomNo2 ]



它会自动添加1,2,依此类推重复的标题名称。但我需要相同的标题名称: -



[SNo] [RoomNo] [SNo] [RoomNo] [SNo] [RoomNo]



我该怎么办..

sir, i create a gridview at runtime with unknown number of columns. basically 2 columns are repeated more then one time. and my gridview header is show like:-


[SNo] [RoomNo] [SNo1] [RoomNo1] [SNo2] [RoomNo2]

it automatically add 1,2 and so on with repeated header name. but i need same header name look like :-

[SNo] [RoomNo] [SNo] [RoomNo] [SNo] [RoomNo]

how can i do it..

推荐答案

填充数据表时,如果数据源中有相同的列名,那么它将会添加数字。



您可以更改数据绑定事件中的gridview标题



When filling datatable, if there are same column name in the datasource then it will add numbers to that.

You can change the gridview header in the Databound event

protected void Gridview2_DataBound(object sender, EventArgs e)
     {

         foreach (TableCell cl in Gridview2.HeaderRow.Cells)
         {
             if (cl.Text.StartsWith("SNo"))
                 cl.Text = "SNo";

             if (cl.Text.StartsWith("RoomNo"))
                 cl.Text = "RoomNo";

         }
     }


这篇关于gridview具有相同的标题名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆