narasiman rao

narasiman rao

  • NA
  • 519
  • 485.7k

how to get the gridview cell value in asp.net

Feb 29 2016 2:10 AM
 Gridview as follows

Link             Course                Code             Days        Startdt                Enddt

Click here        ASM                 CC                  5        10 May 2015     15 May 2015
                                                                               21 May 2015     25 May 2015

When i click the link button in gridview i want to get Course(ASM) for that i written code as follows

protected void LinkButton2_Click(object sender, EventArgs e)
{
for(int i= 0; i < gvRank.Rows.Count; i++)
{
string Course = gvRank.SelectedRow.Cells[1].Text;
Session["course"] = Course;
{
Response.Redirect("Eligibility.aspx");
}
}
}

But When i debug and check in below line as follows

string Course = gvRank.SelectedRow.Cells[1].Text;

In the above line course name is not retrived.

please help me what is the problem in my above code 

Answers (2)