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
C# 从C获取gridview中boundfield的值#_C#_Asp.net - Fatal编程技术网

C# 从C获取gridview中boundfield的值#

C# 从C获取gridview中boundfield的值#,c#,asp.net,C#,Asp.net,我在asp.net中有一个datagrid,带有一个boundfield。在RowCommand事件中,我想获取这个boundfield的值。columns标记中的boundfield如下所示: <asp:BoundField DataField="LoginID" HeaderText="LoginID" InsertVisible="False" ReadOnly="True" SortExpression="LoginID" /> 随之而

我在asp.net中有一个datagrid,带有一个boundfield。在RowCommand事件中,我想获取这个boundfield的值。columns标记中的boundfield如下所示:

<asp:BoundField DataField="LoginID" HeaderText="LoginID" InsertVisible="False" 
                ReadOnly="True" SortExpression="LoginID" />

随之而来的C#是什么


谢谢在Row_命令事件中,您可以通过以下方式检索单击行的索引:

 void GridView_RowCommand(Object sender, GridViewCommandEventArgs e)
  {

    //Check if it's the right CommandName... 
    if(e.CommandName=="Add")
    {
      //Get the Row Index
      int index = Convert.ToInt32(e.CommandArgument);

      // Retrieve the row
      GridViewRow row = ContactsGridView.Rows[index];

      // Here you can access the Row Cells 
      row.Cells[1].Text

    }
  }    

.aspx:

<asp:ImageButton ID="btn_Edit" runat="server"  CommandArgument='<%#((GridViewRow)Container).RowIndex%>' CommandName="editResearch" />    

假设您指的是GridView而不是DataGrid?
<asp:ImageButton ID="btn_Edit" runat="server"  CommandArgument='<%#((GridViewRow)Container).RowIndex%>' CommandName="editResearch" />