citizenzen
Programmer
I have a major problem. i am implementing checkboxes in my gridviews in place of the select link. the checkboxes work fine, but i am unable to clear the data from my child gridviews. the child gridview refreshes (seems to) on pageIndexChanging. I can't figure out how to rebind when the user checks a record that is within the same page block. do i need to implement selectedIndexChanged?? I don't see how to clear the detailsgrid and show data when the checkbox is selected.
here's what i am doing so far.
here's what i am doing so far.
Code:
protected void Page_Load(object sender, EventArgs e)
{ if (!IsPostBack)
{taskListGrid.DataBind();
reqdetsgrid.DataBind();}
private void BindtaskListGrid() //initial grid
{
//connection info here.......
reqDumpDS.Connection.Open();
reqDumpDS.CommandType = CommandType.StoredProcedure;
reqDumpDS.Parameters.Add("@status", SqlDbType.Int, 4);
reqDumpDS.Parameters["@status"].Value = 1;
reqDumpDS.ExecuteNonQuery();
reqDumpDS.Connection.Close();
taskListGrid.DataBind();
taskListGrid.Dispose();
}
protected void taskListGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
{ taskListGrid.PageIndex = e.NewPageIndex;
reqdetsgrid.DataBind(); }
protected void selectReqchk_CheckedChanged(object sender, EventArgs e)
{
RemoveCheckBoxes();
CheckBox checkbox = (CheckBox)sender;
checkbox.Checked = true;
GridViewRow row = (GridViewRow)checkbox.NamingContainer;
BindtaskListDetails();
}
private void RemoveCheckBoxes()
{
foreach (GridViewRow row in taskListGrid.Rows)
{ CheckBox ch = (CheckBox)row.FindControl("selectReqchk");
ch.Checked = false; } }
private void BindtaskListDetails()
{ //uses datatable to bind to gridview
int initialReq = Convert.ToInt32(taskListGrid.DataKeys[1].Value);
detDumpSQL.Connection.Open();
detDumpSQL.CommandType = CommandType.StoredProcedure;
detDumpSQL.Parameters.Add("@req", SqlDbType.Int);
detDumpSQL.Parameters["@req"].Value = initialReq;
//new, declare datatable
DataTable appdetdt = new DataTable();
SqlDataAdapter appdetadap = new SqlDataAdapter(detDumpSQL);
appdetadap.Fill(appdetdt);
reqdetsgrid.DataSource = appdetdt.DefaultView; // appdetdt.DefaultView;
reqdetsgrid.AutoGenerateColumns = false;
//add columns-- temporarially removed for example
reqdetsgrid.Columns.Add(appd1);
reqdetsgrid.DataBind();
detDumpSQL.Connection.Close();
appdetdt.Rows.Clear();
reqdetsgrid.Dispose();
}