LinkButton in GridView not picking correct value
<p>I am using link button to display a pdf report for selected Report Id from Grid view. On page load I am binding the datasource with Gridview. By clicking the link button it fetches the correct report id from column 0 and displays the report. After sorting the grid the grid view shows the sorted data. Now if i click the link button it is not picking the changed value from column 0. instead it is picking the value before sorted.</p>

<p>Say: Column 0 has values 1, 2, 3, 4, 5 before sorting. If i click link button of Row 3 before sorting it is picking value 3 from column 0. After sorting it is 3,4,5,2,1. Now if i click link button of row 3 it is still picking value 3 instead of 5. Can you please help me.</p>

<p>Below is my code:
aspx:


<p>CS:</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
     bindGrid();
}
protected void GvStockTakingReport_Sort(object sender, GridViewSortEventArgs e)
    {

            GvStockTakingReport.DataSource = null;
            GvStockTakingReport.DataBind();
            GvStockTakingReport.Dispose();
            DataSet ds = StockTakingList.BindStocktakingReportGrid();
            DataTable dtSortTable = ds.Tables[0];
            if (dtSortTable != null)
            {
                DataView dv = new DataView(ds.Tables[0]);
                dv.Sort = e.SortExpression + " " + getSortDirectionString();
                //ViewState["sortExpression"] = e.SortExpression;
                //Session["sortExpression"] = e.SortExpression;
                GvStockTakingReport.DataSource = dv;
                GvStockTakingReport.DataBind();
            }                      
       }

   protected void PrintReport(object sender, CommandEventArgs e)
    {

            LinkButton lkButton = (LinkButton)sender;
            GridViewRow item = (GridViewRow)lkButton.NamingContainer;

            string Id = (item.FindControl("lblstk_id") as Label).Text;

            //Getting value for Id    
            string Id1 = e.CommandArgument.ToString();


            int rowIndex = Convert.ToInt32((string)e.CommandArgument);


            //string Id1 = Convert.ToString(GvStockTakingReport.Rows[rowIndex].Cells[0].Text);

            string Id2 = ((Label)(GvStockTakingReport.Rows[rowIndex].FindControl("lblstk_id"))).Text;

            //Getting value for Id

            string virtualPath = string.Format("~/{0}/{1}{2}", Portal.Business, Portal.Core.Profile.ReportsDirectory, "General/RPT_03002_StockTakinReport.rpt");
            string physicalPath = Server.MapPath(virtualPath);

            using (ReportDocument report = new ReportDocument())
            {
                report.Load(physicalPath);
                Core.Security.CrystalReportLogOn(report, (SqlConnectionStringBuilder)Portal.Core.Profile.ConnectionStrings["MTServer"]);
                report.SetParameterValue("@STK_Id", Id);
                report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Page.Response, true, "Stock Taking report");
            }          
    }
</code></pre>
