if(ddlindentno.SelectedItem.Text != "--Select--")
{
foreach (GridViewRow row in GVFeedsaleOrder.Rows)
{
DropDownList ddl = (DropDownList)row.FindControl("ddltype");
DropDownList ddl1 = (DropDownList)row.FindControl("ddlqty");
TextBox txtnufbags = (TextBox)row.FindControl("txtnoofbags");
TextBox txtrateperkg = (TextBox)row.FindControl("txtrateperkg");
if (txtnufbags.Text.Trim() != "" && txtrateperkg.Text.Trim() != "" &&
ddl.SelectedItem.Text != "--Select--" && ddl1.SelectedItem.Text != "--Select--")
{
//CalculateTotal();
objfeedretailPL.sno = Convert.ToInt32(ddlindentno.SelectedValue);
objfeedretailPL.type = Convert.ToInt32(ddl.SelectedValue);
objfeedretailPL.quantity = Convert.ToInt32(ddl1.SelectedItem.Text);
objfeedretailPL.noofbags = Convert.ToInt32(txtnufbags.Text.ToString());
objfeedretailPL.rateperkg = Convert.ToSingle(txtrateperkg.Text.ToString());
objfeedretailPL.username = Session["username"].ToString();
int baginkgs = Convert.ToInt32(ddl1.SelectedItem.Text);
int noofbags = Convert.ToInt32(txtnufbags.Text);
float ratepkg = Convert.ToSingle(txtrateperkg.Text);
float recamt = Convert.ToSingle(lblamtrec.Text.ToString());
float totprvtotal = 0.0f;
totprvtotal = noofbags * ratepkg * ratepkg;
}
}
}
这里我计算动态网格的第一行..现在它总计添加下一行...我可以添加 请帮助我
答案 0 :(得分:1)
float totprvtotal = 0.0f; // Declare a varaible
if(ddlindentno.SelectedItem.Text != "--Select--")
{
foreach (GridViewRow row in GVFeedsaleOrder.Rows)
{
DropDownList ddl = (DropDownList)row.FindControl("ddltype");
DropDownList ddl1 = (DropDownList)row.FindControl("ddlqty");
TextBox txtnufbags = (TextBox)row.FindControl("txtnoofbags");
TextBox txtrateperkg = (TextBox)row.FindControl("txtrateperkg");
if (txtnufbags.Text.Trim() != "" && txtrateperkg.Text.Trim() != "" &&
ddl.SelectedItem.Text != "--Select--" && ddl1.SelectedItem.Text != "--Select--")
{
//CalculateTotal();
objfeedretailPL.sno = Convert.ToInt32(ddlindentno.SelectedValue);
objfeedretailPL.type = Convert.ToInt32(ddl.SelectedValue);
objfeedretailPL.quantity = Convert.ToInt32(ddl1.SelectedItem.Text);
objfeedretailPL.noofbags = Convert.ToInt32(txtnufbags.Text.ToString());
objfeedretailPL.rateperkg = Convert.ToSingle(txtrateperkg.Text.ToString());
objfeedretailPL.username = Session["username"].ToString();
int baginkgs = Convert.ToInt32(ddl1.SelectedItem.Text);
int noofbags = Convert.ToInt32(txtnufbags.Text);
float ratepkg = Convert.ToSingle(txtrateperkg.Text);
float recamt = Convert.ToSingle(lblamtrec.Text.ToString());
totprvtotal = noofbags * ratepkg * ratepkg;
}
}
}
归功于@Ashish Charan
答案 1 :(得分:1)
请在下面试试......
if(ddlindentno.SelectedItem.Text != "--Select--")
{
float totprvtotal = 0.0f;
foreach (GridViewRow row in GVFeedsaleOrder.Rows)
{
DropDownList ddl = (DropDownList)row.FindControl("ddltype");
DropDownList ddl1 = (DropDownList)row.FindControl("ddlqty");
TextBox txtnufbags = (TextBox)row.FindControl("txtnoofbags");
TextBox txtrateperkg = (TextBox)row.FindControl("txtrateperkg");
if (txtnufbags.Text.Trim() != "" && txtrateperkg.Text.Trim() != "" &&
ddl.SelectedItem.Text != "--Select--" && ddl1.SelectedItem.Text != "--Select--")
{
//CalculateTotal();
objfeedretailPL.sno = Convert.ToInt32(ddlindentno.SelectedValue);
objfeedretailPL.type = Convert.ToInt32(ddl.SelectedValue);
objfeedretailPL.quantity = Convert.ToInt32(ddl1.SelectedItem.Text);
objfeedretailPL.noofbags = Convert.ToInt32(txtnufbags.Text.ToString());
objfeedretailPL.rateperkg = Convert.ToSingle(txtrateperkg.Text.ToString());
objfeedretailPL.username = Session["username"].ToString();
int baginkgs = Convert.ToInt32(ddl1.SelectedItem.Text);
int noofbags = Convert.ToInt32(txtnufbags.Text);
float ratepkg = Convert.ToSingle(txtrateperkg.Text);
float recamt = Convert.ToSingle(lblamtrec.Text.ToString());
totprvtotal = noofbags * ratepkg * ratepkg + totprvtotal;
}
}
}