Passing control identifier from Linkbutton to gridview

How to pass control identifier in gridview, which is obtained from the stored procedure into a variable. I will use the variable to go to the database later to return some results. Thank.

+1
source share
2 answers
var controlId = ((LinkButton)gridView1.Rows[0].FindControl("lbName")).Id;

Are you trying to do something like the above?

Update
You can use the OnSelectedIndex event for the GridView to find the selected row.

  void GridView_SelectedIndexChanged(Object sender, EventArgs e)
  {
    // Get the currently selected row using the SelectedRow property.
    GridViewRow row = CustomersGridView.SelectedRow;

    var controlId = ((LinkButton)row.FindControl("lbName")).Id;
  }
+1
source

I usually use the CommandName and CommandArgument fields with LinkButtons in a GridView.

CommandName , , , CommandArgument - .

RowCommand GridView

0

All Articles