I'm trying to add the value of a result from my while
, then load it into my GridView
. But I'm having a problem adding the value to my List<>
. You can not add prob1.vTotal
to lstTotal
.
namespace AvalicaoPratica.View
{
public partial class Home : System.Web.UI.Page
{
List<_Problema1> lstTotal = new List<_Problema1>();
protected void Page_Load(object sender, EventArgs e)
{
_Problema1 prob1 = new _Problema1();
while (prob1.Cont <= 64)
{
prob1.Vtotal = prob1.Vtotal + prob1.Graos;
prob1.Graos = prob1.Graos * 2;
prob1.Cont += 1;
}
lstTotal.Add(prob1.Vtotal);
GridView1.DataSource = lstTotal;
GridView1.DataBind();
}
}
}
My class
public class _Problema1
{
private int vtotal = 0;
public int Vtotal
{
get { return vtotal; }
set { vtotal = value; }
}
private int cont;
public int Cont
{
get { return cont; }
set { cont = value; }
}
private int graos = 1;
public int Graos
{
get { return graos; }
set { graos = value; }
}
}