1
Answer

How to get row index value in link button in gridview

jaya sai

jaya sai

1y
806
1

i can able to get the row index but i want to get beneficiaryID based on that i need to display remaining column values i unable to bind the selected row value pls help me

 My Code

protected void lnkbtnView_Click(object sender, EventArgs e)
{
     LinkButton button = (LinkButton)sender;
     GridViewRow row = (GridViewRow)button.NamingContainer;
     if (row != null)
     {
         int i = row.RowIndex;
     }
     DataTable dt = new DataTable();
     lblBenId.Text = dt.Rows[0]["BeneficiaryID"].ToString();
     lblBenCode.Text = dt.Rows[0]["BeneficiaryCode"].ToString();
     lblBenName.Text = dt.Rows[0]["BeneficiaryName"].ToString();
     lblAccountNumber.Text = dt.Rows[0]["AccountNumber"].ToString();
     lblIFSC.Text = dt.Rows[0]["IFSC"].ToString();
     lblNameAsPerBank.Text = dt.Rows[0]["NameAsPerBank"].ToString();
}

 

Answers (1)