hello,
if i have 3 gridview same html page
can i use same OnRowDeleting and OnRowDataBound
i did add first one OnRowDeleting and OnRowDataBound working
can add also for second and third OnRowDeleting and OnRowDataBound because when i try add am getting error
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
//rasmi
if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowIndex != GridView2.EditIndex)
{
string namerm = (e.Row.FindControl("txtUsernamelb0") as Label).Text;
string daterm = Convert.ToDateTime((e.Row.FindControl("lblBoxDateadd3") as Label).Text).ToString("dd/MM/yyyy");
foreach (LinkButton button in e.Row.Cells[7].Controls.OfType<LinkButton>())
{
if (button.CommandName == "Delete")
{
button.Attributes["onclick"] = "if(!confirm('Do you want to delet\\nأسم الموظف\\n"
+ namerm + "\\nتاريخ المهمة الرسمية\\n" + daterm + "')){ return false; };";
}
}
}
//EME
if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowIndex != GridView3.EditIndex)
{
string nameeme = (e.Row.FindControl("txtUsernamelb1") as Label).Text;
string dateeme = Convert.ToDateTime((e.Row.FindControl("lblBoxDateadd5") as Label).Text).ToString("dd/MM/yyyy");
foreach (LinkButton button in e.Row.Cells[6].Controls.OfType<LinkButton>())
{
if (button.CommandName == "Delete")
{
button.Attributes["onclick"] = "if(!confirm('Do you want to delet\\nأسم الموظف\\n"
+ nameeme + "\\nتاريخ الاجازة الطارئة\\n" + dateeme + "')){ return false; };";
}
}
}
}
protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
{
int index = Convert.ToInt32(e.RowIndex);
int Id = Convert.ToInt32(GridView2.DataKeys[e.RowIndex].Values[0]);
string constr = ConfigurationManager.ConnectionStrings["kankonConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("Rsmi"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Action", "DELETE");
cmd.Parameters.AddWithValue("@Id", Id);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
BindGrid2Rasmisearch();
}
int index2 = Convert.ToInt32(e.RowIndex);
int Id2 = Convert.ToInt32(GridView3.DataKeys[e.RowIndex].Values[0]);
string constr2 = ConfigurationManager.ConnectionStrings["kankonConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr2))
{
using (SqlCommand cmd = new SqlCommand("EME"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Action", "DELETE");
cmd.Parameters.AddWithValue("@Id", Id2);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
BindGrid3EMEsearch();
}
}