Hi all again, i have a bit of a problem in this matter, hope that
anyone can point me in the right direction, the scenario its as follows:
I have a gridview, with about 200 rows, so i decided to
page it, 10 rows per page; on each row i have a checkbox(not a gridview
checkbox field, but a checkbox inside a template field, i was unhable
to use the gridview checkbox´s field cause it was read only and y need
to edit it in runtime). My problem comes when i want to set the
checkbox to checked and the record its not on the first page, here´s
some of my code:
protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView2.PageIndex = e.NewPageIndex;
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["LocalSQLServer"]);
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand Cmnd = new SqlCommand();
Cmnd.CommandText = "SELECT * FROM Customers";
Cmnd.Connection = conn;
conn.Open();
da.SelectCommand = Cmnd;
da.SelectCommand.ExecuteNonQuery();
DataSet ds = new DataSet();
da.Fill(ds);
GridView2.DataSource = ds;
GridView2.DataBind();
for (int i = GridView2.PageIndex * 10; i < (GridView2.PageIndex * 10) + 9; i++)
{
DataRow dtRow = ds.Tables[0].Rows[i];
if (bool.Parse(dtRow["BitField"].ToString()) == true)
{
GridViewRow row = GridView2.Rows[i];
((CheckBox)row.FindControl("CheckBox")).Checked = true;
}
}
conn.Close();
}
My problem comes when i try to create the GridViewRow object row, cause the i in GridView2.Rows[i], has a maximun value equal to the amount of records PER PAGE, with that in mind i tryed the above code, BUT, i still dont know how to select a specific page in order to set the correspondig checkbox(a page different form the 1st one), cause the i will only go as far as 9(only reference the rows on the 1st page).
Any Ideas?
I hope i have make myself clear enough on this one, again pardon for my english and tnks in advance for the help.
Farewell
Leandro