简体   繁体   English

将值从GridView中复制到TextBox中

[英]Copy value from in a GridView into a TextBox

I have a GridView from where I want to get a text value from cell in column 26 in the selected row into an TextBox (named txtResult ). 我有一个GridView ,我想从其中从所选行的第26列的单元格中获取一个文本值到一个TextBox (名为txtResult )。 Cell is not visible (its Visible property is false ). 单元格不可见(其Visible属性为false )。

I tried this: 我尝试了这个:

txtResult.Text = grdMyGrid.SelectedRow.Cells[26].Text;

Thanks for your help in advance! 谢谢您的帮助!

Don't set the invisibility on the regular column properties on the code behind (.aspx), do it throught the RowDataBound event. 不要在(.aspx)后面的代码上的常规列属性上设置隐身性,请通过RowDataBound事件来实现。 I believe this way you will get the value. 我相信这样您将获得价值。

您最好尝试以下代码:

dataGridView1.SelectedRows[0].Cells["ColummName"].Value.ToString();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM