Click here to Skip to main content
15,911,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The error is with:
C#
highscores[0] = new Percentage("098", "2014/02/01", "78");
highscores[1] = new Percentage("078", "2014/05/15", "68");
highscores[2] = new Percentage("045", "2014/09/16", "71");

Code:
C#
public class Percentage
{
    public string id { get; set; }
    public string DateTime { get; set; }
    public string Percent { get; set; }
}
protected void btn2(object sender, EventArgs e)
{
    Percentage[] highscores = new Percentage[3];
    highscores[0] = new Percentage("098", "2014/02/01", "78");
    highscores[1] = new Percentage("078", "2014/05/15", "68");
    highscores[2] = new Percentage("045", "2014/09/16", "71");
    highscores = highscores.OrderByDescending(s => s.Percent).ToArray();

    GridView1.DataSource = highscores;
    GridView1.DataBind();
}

Error code:
'theScore._Default.Percentage' does not contain a constructor that takes 3 arguments	C:\Users\user\path\Default.aspx.cs
Posted

1 solution

The way you are working class is wrong.

Do like this.


C#
protected void btn2(object sender, EventArgs e)
       {
           List<percentage> objPercentage = new List<percentage>();
           objPercentage.Add(new Percentage{ id="098", DateTime="2014/02/0", Percent="78"});
           objPercentage.Add(new Percentage{ id="099", DateTime="2014/02/0", Percent="68"});
           objPercentage.Add(new Percentage{ id="099", DateTime="2014/02/0", Percent="68"});

           GridView1.DataSource = objPercentage;
           GridView1.DataBind();
       }
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900