Hi,
I have created a search page where it has some parameters which user need to fill and in below grid it will display the results.
In my grid I have the request no field as hyper link and when user click on request no link it will open the detail of that request no.
My issue is in grid view paging first page is coming fine but when I go to next page all the request no of the next page passes the previous page request no in query string in hper link field.
for example my request no is REQ01 and first page in hyper link I am pssing the REQ01 as query string to get the detail of this request.
Now on next page suppose I have REQ02 it shoudl pass REQ02 in query string but instead it is passing REQ01.
Can any body help me to fix this issue.
below is my code.
DataTable dt;
string Query;
protected void Page_Load(object sender, EventArgs e)
{
}
public string getconn()
{
return Suggestion_DAL.GetConnection();
}
public string GetDesc(string Query, string Id)
{
string Desc = string.Empty;
SqlConnection sqlcon = new SqlConnection(getconn());
SqlCommand sqlcomm = new SqlCommand(Query + Id + "'", sqlcon);
sqlcon.Open();
Desc = sqlcomm.ExecuteScalar().ToString();
sqlcon.Close();
return Desc;
}
public void PopulateGrid()
{
Query = "select * from Request order by modified Desc";
HttpContext.Current.Response.Write(Query);
HttpContext.Current.Response.Write(ddlDepartment.SelectedItem.Text);
SqlConnection sqlcon = new SqlConnection(getconn());
SqlDataAdapter oAdapter = new SqlDataAdapter(Query, sqlcon);
DataSet ds = new DataSet();
oAdapter.Fill(ds);
dt = ds.Tables[0];
if (dt.Rows.Count > 0)
{
gridViewReport.DataSource = dt;
gridViewReport.DataBind();
}
else
{
Vlable.Text = "No record found.";
}
}
protected void gridViewReport_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int index = ((gridViewReport.PageSize) * (gridViewReport.PageIndex)) + e.Row.RowIndex;
string strdocurl = dt.Rows[index]["Sno"].ToString();
e.Row.Cells[0].Text = "<a href='detail.aspx?VID=" + dt.Rows[e.Row.RowIndex]["Sno"] + "'>REQ" + strdocurl + "<a/>";
}
}
protected void gridViewReport_PageIndexChanged(object sender, GridViewPageEventArgs e)
{
gridViewReport.DataSource = dt;
gridViewReport.PageIndex = e.NewPageIndex;
gridViewReport.DataBind();
PopulateGrid();
}
protected void btnApply_Click(object sender, EventArgs e)
{
PopulateGrid();
}