PDA

View Full Version : جمع ستون ها در گرید ویو



myysl97
دوشنبه 17 اسفند 1394, 05:46 صبح
سلام دوستان
چطوری من در یک گرید ویو یک ستون رو جمع کنم فاکتور صادر کنم؟(مثلا ستون قیمت )
مرسی

rezashaban
دوشنبه 17 اسفند 1394, 05:54 صبح
سلام دوست من
از این کد استفاده کن


Int32 tot = 0;
protected void Dg_Source_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
tot = tot + Convert.ToInt32(e.Row.Cells[1].Text);
lblSum.Text = tot.ToString();
}
}

myysl97
دوشنبه 17 اسفند 1394, 06:09 صبح
ممنون ولی این ارور رو میده



Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:

Line 110: if (e.Row.RowType == DataControlRowType.DataRow)
Line 111: {
Line 112: tot = tot + Convert.ToInt32(e.Row.Cells[1].Text);
Line 113: //Label lblTotalPrice = (Label)e.Row.FindControl("lblTotalPrice");
Line 114: //lblTotalPrice.Text = tot.ToString();

myysl97
دوشنبه 17 اسفند 1394, 06:11 صبح
به این قسمت ایراد میگیره
tot = tot + Convert.ToInt32(e.Row.Cells[1].Text);

rezashaban
دوشنبه 17 اسفند 1394, 06:17 صبح
خب حتما یه سلول خالی داری یا آدرس ستونی که میخوای جمع برنی رو اشتباه دادی