To Work With GridView In Outside Or Internal Event Of Any Control Except
protected void txtDispQty_TextChanged(object sender, EventArgs e)
{
ltTotAmt.Text = "0";
for (int i = 0; i < gvSaleDispatch.Rows.Count; i++)
{
if (((TextBox)gvSaleDispatch.Rows[i].FindControl("txtDispQty")).Text != "")
{
if (Convert.ToDouble(((TextBox)gvSaleDispatch.Rows[i].FindControl("txtDispQty")).Text) > Convert.ToDouble(((Label)gvSaleDispatch.Rows[i].FindControl("lblOrdQty")).Text))
{
((TextBox)gvSaleDispatch.Rows[i].FindControl("txtDispQty")).Text = "";
CloseWindow = "alert('Dispatch Quantity cant be greater than Ordered Quantity....');";
ClientScript.RegisterStartupScript(this.GetType(), "CloseWindow", CloseWindow, true);
}
else if (Convert.ToDouble(((TextBox)gvSaleDispatch.Rows[i].FindControl("txtDispQty")).Text) > Convert.ToDouble(((Label)gvSaleDispatch.Rows[i].FindControl("lblAvailStock")).Text))
{
((TextBox)gvSaleDispatch.Rows[i].FindControl("txtDispQty")).Text = "";
CloseWindow = "alert('Dispatch Quantity cant be greater than Available Stock....');";
ClientScript.RegisterStartupScript(this.GetType(), "CloseWindow", CloseWindow, true);
}
else
{
((Label)gvSaleDispatch.Rows[i].FindControl("lbltot")).Text = String.Format("{0:0.00}", (Convert.ToDouble(((TextBox)gvSaleDispatch.Rows[i].FindControl("txtDispQty")).Text) * Convert.ToDouble(((Label)gvSaleDispatch.Rows[i].FindControl("lblRate")).Text)));
ltTotAmt.Text = String.Format("{0:0.00}", (Convert.ToDouble(ltTotAmt.Text) + Convert.ToDouble(((Label)gvSaleDispatch.Rows[i].FindControl("lbltot")).Text)));
}
}
}
ltTotPayableAmt.Text = ltTotAmt.Text;
}
protected void txtDispQty_TextChanged(object sender, EventArgs e)
{
ltTotAmt.Text = "0";
for (int i = 0; i < gvSaleDispatch.Rows.Count; i++)
{
if (((TextBox)gvSaleDispatch.Rows[i].FindControl("txtDispQty")).Text != "")
{
if (Convert.ToDouble(((TextBox)gvSaleDispatch.Rows[i].FindControl("txtDispQty")).Text) > Convert.ToDouble(((Label)gvSaleDispatch.Rows[i].FindControl("lblOrdQty")).Text))
{
((TextBox)gvSaleDispatch.Rows[i].FindControl("txtDispQty")).Text = "";
CloseWindow = "alert('Dispatch Quantity cant be greater than Ordered Quantity....');";
ClientScript.RegisterStartupScript(this.GetType(), "CloseWindow", CloseWindow, true);
}
else if (Convert.ToDouble(((TextBox)gvSaleDispatch.Rows[i].FindControl("txtDispQty")).Text) > Convert.ToDouble(((Label)gvSaleDispatch.Rows[i].FindControl("lblAvailStock")).Text))
{
((TextBox)gvSaleDispatch.Rows[i].FindControl("txtDispQty")).Text = "";
CloseWindow = "alert('Dispatch Quantity cant be greater than Available Stock....');";
ClientScript.RegisterStartupScript(this.GetType(), "CloseWindow", CloseWindow, true);
}
else
{
((Label)gvSaleDispatch.Rows[i].FindControl("lbltot")).Text = String.Format("{0:0.00}", (Convert.ToDouble(((TextBox)gvSaleDispatch.Rows[i].FindControl("txtDispQty")).Text) * Convert.ToDouble(((Label)gvSaleDispatch.Rows[i].FindControl("lblRate")).Text)));
ltTotAmt.Text = String.Format("{0:0.00}", (Convert.ToDouble(ltTotAmt.Text) + Convert.ToDouble(((Label)gvSaleDispatch.Rows[i].FindControl("lbltot")).Text)));
}
}
}
ltTotPayableAmt.Text = ltTotAmt.Text;
}
No comments:
Post a Comment