i have a cms system, after a user logins to the system, there is a page with a gridview hwich has a column of checkboxes in it. there is a button on the page to delete records selected in the gridview using the checkbox. when press on this button, the records get deleted. now there is also a column of edit buttons in the gridview. after the delete operation, when i click on the edit button, the session ends i am redirected to the login page, here's the code for delete button:-
Code:
try
{
string id = string.Empty;
foreach (GridViewRow gv in GridView1.Rows)
{
CheckBox chkselectItem = (CheckBox)gv.FindControl("CheckBox1");
if (chkselectItem.Checked)
{
id = ((DataKey)GridView1.DataKeys[gv.RowIndex]).Value.ToString();
chkid.Add(id);
}
}
if (chkid.Count <= 0)
{
lblMessage.Text = "Please Select a Meeting to delete";
}
else
{
for (int i = 0; i < chkid.Count; i++)
{
DeleteMeeting(chkid[i].ToString());
string query = "delete from tblBMeeting where id=" + chkid[i].ToString();
int res = dba.Insert(query);
if (res == 0)
{
//DeleteMeeting(chkid[i].ToString());
lblMessage.Text += "Meeting Removed";
}
else
{
//lblMessage.Text = query;
break;
}
}
}
fillGrid(ddlForums.SelectedValue);
}
catch (Exception ex)
{
ErrorLoging.logerror(ex.Message, "Meetings");
}
here's the code for validating Session in master page.
Code:
if (String.IsNullOrEmpty((String)Session["user"]))
FormsAuthentication.RedirectToLoginPage();