获取Gridview列值到数据集(逗号分隔) [英] Get Gridview column value to dataset (comma separeted)

查看:88
本文介绍了获取Gridview列值到数据集(逗号分隔)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< asp:BoundField DataField =   Id HeaderText =   Id ReadOnly =  < span class =code-string> True SortExpression =   Id 
ItemStyle-CssClass = ItemPixel />



如何从c#的gridview列中获取所有值。



使用数据源绑定网格



ID

1

2

3



我想要1,2,3 in c#ON按钮点击事件

解决方案

尝试

  string  index =  string  .empty; 
foreach (GridViewRow行 GridView1.Rows)
{
index = index + + Convert.ToString(GridView1.Cells [ 0 ]值);
}
return index,substring( 0 ,index.Length - 2 );


<asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id"
                                    ItemStyle-CssClass="ItemPixel" />


How to get all the values from this column of gridview in c#.

Binding grid using Datasource

ID
1
2
3

I want 1,2,3 in c# ON button click event

解决方案

Try

string index = string.empty;
foreach(GridViewRow row in GridView1.Rows)
{
    index = index + "," + Convert.ToString(GridView1.Cells[0].Value);
}
return index,substring(0, index.Length - 2);


这篇关于获取Gridview列值到数据集(逗号分隔)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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