我可以在Rowdatabound期间将一个列值存储到数组变量 [英] Can I Store One Column Value To Array Variable During Rowdatabound

查看:44
本文介绍了我可以在Rowdatabound期间将一个列值存储到数组变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在程序的其他位置使用一个列值。



我该怎么做?



提前感谢你。

I want to use one column value somwhere else in the program.

How can i do that?

Thanking You in advance.

推荐答案

下面给出一个例子

One example given below
List<string> FirstColumn=new List<string>();
void GridView1_RowDataBound(Object sender, GridViewRowEventArgs e)
  {

    if(e.Row.RowType == DataControlRowType.DataRow)
    {
      // Display the company name in italics.
      FirstColumn.Add(e.Row.Cells[1].Text);

    }

  }
</string></string>






以上问题应该解决你。



您必须与集合或数据表绑定。因此您不需要使用RowDataBound事件。你可以使用下面的LINQ查询来解决你的问题:



Hi,

Above problem should solve you.

You must be binding with the collection or the data table. So you don't need to use the RowDataBound event. You can use the below LINQ query to solve your problem:

string[] columnValues = 
                         (from row in dt.AsEnumerable()
                         select row["column"].ToString()).ToArray<string>();





谢谢



Thanks


这篇关于我可以在Rowdatabound期间将一个列值存储到数组变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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