execute query after qty change in label.
i am displaying gridview column total in lbtotal label which is outside gridview
i want when i delete row from gridview, then total of column get update into lbtotal then update tblPackM table
Column total
Decimal TotalValueq = 0;
protected void GVallbb_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
Label lblq = (Label)e.Row.FindControl("QTY1");
TotalValueq += Convert.ToDecimal(lblq.Text);
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
Label lblq = (Label)e.Row.FindControl("lblTotal");
lblq.Text = TotalValueq.ToString();
lbtotal.Text = TotalValueq.ToString();
}
}
I displaying column total in label lbtotal and i am deleting row from gridview
protected void GVallbb_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
if (txtptype.Text == lbtotal.Text)
{
Response.Write("<script>alert('Please Check Type...')</script>");
}
else
{
GridViewRow row = GVallbb.Rows[e.RowIndex];
int Prdno = Convert.ToInt32(GVallbb.DataKeys[e.RowIndex].Values[0]);
int PDID = Convert.ToInt32(GVallbb.DataKeys[e.RowIndex].Values[1]);
using (SqlCommand cmd = new SqlCommand("UPDATE Probale SET PID = '1' WHERE Prdno = @Prdno", con))
using (SqlCommand cmd1 = new SqlCommand("UPDATE tbl_PckDetail SET DelID = '1',P_Status='P',DDate=@DDate,DTime=@DTime,IPAddress=@IPAddress WHERE PDID = @PDID", con))
{
cmd.Parameters.AddWithValue("@Prdno", Prdno);
cmd1.Parameters.AddWithValue("@PDID", PDID);
cmd1.Parameters.AddWithValue("@DDate", DateTime.Now.ToString());
cmd1.Parameters.AddWithValue("@DTime", DateTime.Now.ToString("hh:mm"));
cmd1.Parameters.AddWithValue("@IPAddress", lblIP.Text);
cmd.Connection = con;
cmd1.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
cmd1.ExecuteNonQuery();
con.Close();
}
}
}
Now i want to execute below query when lbtotal value get change after deleting event of gridview
private void Updatepacktype()
{
SqlCommand cmd = new SqlCommand("UPDATE tbl_BalPacM SET PType=@Ptype WHERE PID = @PID", con);
cmd.CommandType = CommandType.Text;
{
cmd.Parameters.AddWithValue("@PType", lbtotal.Text);
cmd.Parameters.AddWithValue("@PID", txtPack.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();