[解决]我想在单击数据网格上的任何列时选择整行。 [英] [Solved]I want to select the entire row when I click on any column on Data Grid.

查看:57
本文介绍了[解决]我想在单击数据网格上的任何列时选择整行。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的代码,它显示我的错误

索引超出范围。必须是非负的且小于集合的大小。





我的代码

 txt_Name.Text = GridView1.SelectedRows [ 0 ]。单元格[ 0 ]。 Value.ToString(); 
txt_Email.Text = GridView1.SelectedRows [ 0 ]。单元格[ 1 ]。值。的ToString();
txt_Mobile.Text = GridView1.SelectedRows [ 0 ]。单元格[ 2 ]。值。的ToString();
txt_Address.Text = GridView1.SelectedRows [ 0 ]。单元格[ 3 ]。值。的ToString();
txt_Company.Text = GridView1.SelectedRows [ 0 ]。单元格[ 4 ]。值。的ToString();

解决方案
回答只从未应答列表中删除:由OP解决

Following are my code and it shows me error
index was out of range. must be non-negative and less than the size of the collection.


My Code

txt_Name.Text = GridView1.SelectedRows[0].Cells[0].Value.ToString();
            txt_Email.Text = GridView1.SelectedRows[0].Cells[1].Value.ToString();
            txt_Mobile.Text = GridView1.SelectedRows[0].Cells[2].Value.ToString();
            txt_Address.Text = GridView1.SelectedRows[0].Cells[3].Value.ToString();
            txt_Company.Text = GridView1.SelectedRows[0].Cells[4].Value.ToString();

解决方案

Answered only to remove from unanswered list: solved by OP


这篇关于[解决]我想在单击数据网格上的任何列时选择整行。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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