
展开全部
GridView1.Rows[0].Cells[0] 表示第0行第0列的值 GridView1在很多事件里面都可以利用这一个方式获得相应的值
假如我要获取 点击行的数据 就可以在
GridView1 的RowCommand事件里面这样写
string value = this.GridView1.Rows[Convert.ToInt32(e.CommandArgument)
].Cells[0].Text;
如果在其他方法里面获得GridView1 的数据 可以巧用这个方式
int i=0;
foreach (GridViewRowCollection row in GridView1.Rows)
{
for (int cellIndex = 0; cellIndex < row[i].Cells.Count; cellIndex++)
{
string value = row[i].Cells[cellIndex].Text;
}
i++;
}
都用for循环 或 其他循环都可以 看自己喜欢了
只是提供个思路了 很多 控件都可以巧用他们的属性 这个不错的选择
GridView1.FindControl("在GridView1里面的控件id名称"); FindControl()是个非常好用的方法
假如我要获取 点击行的数据 就可以在
GridView1 的RowCommand事件里面这样写
string value = this.GridView1.Rows[Convert.ToInt32(e.CommandArgument)
].Cells[0].Text;
如果在其他方法里面获得GridView1 的数据 可以巧用这个方式
int i=0;
foreach (GridViewRowCollection row in GridView1.Rows)
{
for (int cellIndex = 0; cellIndex < row[i].Cells.Count; cellIndex++)
{
string value = row[i].Cells[cellIndex].Text;
}
i++;
}
都用for循环 或 其他循环都可以 看自己喜欢了
只是提供个思路了 很多 控件都可以巧用他们的属性 这个不错的选择
GridView1.FindControl("在GridView1里面的控件id名称"); FindControl()是个非常好用的方法
展开全部
给你看段代码:
// 0代表第一列 以此类推... dataGridView1.CurrentCell.RowIndex代表当前选中的行
string str1 = dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString();
string str2 = dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString();
string str3 = dataGridView1[2, dataGridView1.CurrentCell.RowIndex].Value.ToString();
// 0代表第一列 以此类推... dataGridView1.CurrentCell.RowIndex代表当前选中的行
string str1 = dataGridView1[0, dataGridView1.CurrentCell.RowIndex].Value.ToString();
string str2 = dataGridView1[1, dataGridView1.CurrentCell.RowIndex].Value.ToString();
string str3 = dataGridView1[2, dataGridView1.CurrentCell.RowIndex].Value.ToString();
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
说的很模糊,到底是什么样的值。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询