ASP.Net DataGrid列名称 [英] ASP.Net DataGrid Column Names

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

问题描述

是否有一种方法可以命名数据网格的列,从而能够
用名字来称呼他们?我知道dgTemp.Columns(8)的概念;但是,如果我
指的是Column(8),稍后,我在datagrid中插入一列,在那之前
专栏,我必须了解和调整后面代码中的所有索引引用.

还是有一个基于列的HeaderText返回列索引的函数?

谢谢,
Steve

Is there a way to name the columns of a datagrid in such a way as to be able to
refer to them by name? I''m aware of the dgTemp.Columns(8) concept; however, if I''m
referring to Column(8) and at a later date, I insert a column in the datagrid before that
column, I have to know and adjust all of the index references in the code behind.

Or is there a function which returns the column index based on the HeaderText of the column?

Thanks,
Steve

推荐答案

您总是可以编写一个小的转换器实用程序,该实用程序接受一个datagrid对象和一个请求的标头文本,以返回适当的列索引.
You could always write a small converter utility that takes in a datagrid object and a requested header text returning the appropriate column index.
private int GetColumnIndexByHeaderText( DataGrid dgObj, string headerText )
{
   // Loop through the columns and when you find the appropriate header text return the index.
}


这篇关于ASP.Net DataGrid列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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