gridview中的标题列 [英] header column in gridview

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

问题描述

我的朋友

i在gridview中显示数据

  string  sql =   select * +   from table_name其中t.months ='2014/05' 
+ order by 1 DESC;

OracleCommand command = new OracleCommand(sql,conn);
command.CommandType = CommandType.Text;
OracleDataAdapter adapter = new OracleDataAdapter(command);

DataSet dataset = new DataSet();
adapter = new OracleDataAdapter(command);
adapter.Fill(dataset);

command.ExecuteNonQuery();
GridView1.DataSource = dataset.Tables [ 0 ];
GridView1.DataBind();


当我写

 GridView1.Columns [ 1 ] .HeaderText =   mytext; 





显示错误:



指数超出范围。必须是非负数且小于集合的大小。\\\\ n参数名称:index



任何人都可以帮我PLZ





谢谢

解决方案

确保您的列索引从0开始列,你应该在你的总列范围之间输入列索引


试试这个



GridView1.HeaderRow .Cells [I]。文本= ABC;

my friends
i showing data in gridview

string sql = "select * "                                                                                                 + "   from table_name where t.months = '2014/05'"
                      + " order by 1 DESC";

           OracleCommand command = new OracleCommand(sql, conn);
           command.CommandType = CommandType.Text;
           OracleDataAdapter adapter = new OracleDataAdapter(command);

           DataSet dataset = new DataSet();
           adapter = new OracleDataAdapter(command);
           adapter.Fill(dataset);

           command.ExecuteNonQuery();
           GridView1.DataSource = dataset.Tables[0];
           GridView1.DataBind();


i am facing problem when i write

GridView1.Columns[1].HeaderText = "mytext";



it showing Error :

Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index

can any body help me PLZ


thanks

解决方案

Make sure your column index starting from "0" while giving into the columns, and you should enter the column index in between the range of your total columns


try this

GridView1.HeaderRow.Cells[i].Text="ABC";


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

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