2
Answers

how to get the gridview cell value in asp.net

narasiman rao

narasiman rao

8y
397
1
 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)