Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 在vb.net中单击时从datagridview获取隐藏的sql id_Mysql_Vb.net_Datagridview - Fatal编程技术网

Mysql 在vb.net中单击时从datagridview获取隐藏的sql id

Mysql 在vb.net中单击时从datagridview获取隐藏的sql id,mysql,vb.net,datagridview,Mysql,Vb.net,Datagridview,您好,我正在尝试从vb.net中的datagridview获取sql id。当数据网格显示时,我已经能够从中获取id。但是,这一次我想获得datagrid中所选单元格的隐藏唯一id 我有这个密码 如果e.RowIndex>=0,则 将行变暗为DataGridViewRow row=Me.DataGridView1.Rowse.RowIndex TextBox1.Text=row.CellsUNIQUE_ID.Value.ToString 尝试 连接,打开 暗选线 sel=从ngp.ngpmai

您好,我正在尝试从vb.net中的datagridview获取sql id。当数据网格显示时,我已经能够从中获取id。但是,这一次我想获得datagrid中所选单元格的隐藏唯一id

我有这个密码

如果e.RowIndex>=0,则 将行变暗为DataGridViewRow row=Me.DataGridView1.Rowse.RowIndex TextBox1.Text=row.CellsUNIQUE_ID.Value.ToString 尝试 连接,打开 暗选线 sel=从ngp.ngpmain中选择*,其中UNIQUE_ID='&TextBox1.Text&' com=新的MySqlCommandsel,连接 reader=com.ExecuteReader 边读边读 Add.TextBox7.Text=TextBox1.Text 结束时 特例 MsgBoxex.Message End Try使用DataGridViewRow.DataBoundItem属性访问基础DataRow:


此代码假定您正在将DataGridView1.DataSource绑定到DataTable,然后将DataGridView1.AutoGenerateColumns设置为False并手动定义可见列。绑定数据中必须有唯一的\u ID。

尝试访问DataGridView的.DataSource属性而不是DataGridView的DataTable。
If e.RowIndex >= 0 Then
  Dim row As DataGridViewRow
  row = Me.DataGridView1.Rows(e.RowIndex)
  Dim drow As DataRow = DirectCast(row.DataBoundItem, DataRowView).Row
  TextBox1.Text = drow("UNIQUE_ID").ToString