Click here to Skip to main content
15,888,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
when we select value from dropdown then i try to display highcharts according to dropdown value for this i try this

What I have tried:

C#
[WebMethod]
public static string jqufunc(int year)
{

    string res = "[";
    ProjectdbEntities a = new ProjectdbEntities();

    var b = a.Catg_type;
    //a.spstdinfo();
    foreach (var c in b)
    {
        res += "'" + c.Catg_type1 + "',";
    }
    res = res.Substring(0, res.Length - 1);
    res += "]";
    //for program type
    var allprogs = a.Program_type;
    string res2 = "[";
    foreach (var pr in allprogs)
    {
        res2 += "{name: '" + pr.Prog_name + "',";


        //for year
        var yearget = a.Year_info;
        foreach (var yg in yearget)
        {
            res2 += "'" +yg.year + "',";


            //for cat
            var allcats = a.Catg_type;

            res2 += "data:[";

            foreach (var ct in allcats)
            {
                res2 += a.Std_info.Where(t => t.Catg_id == ct.Catg_id && t.Prog_id == pr.Prog_id && t.year_id=yg.year_id).Count().ToString() + ",";
            }

            res2 = res2.Substring(0, res2.Length - 1);
            res2 += "]";
            res2 += "},";



        }
        res2 = res2.Substring(0, res2.Length - 1);
        res2 += "]";
        return res + "*" + res2;

    }
}


here year is in int

when i build error occur on this line

res2 += a.Std_info.Where(t => t.Catg_id == ct.Catg_id && t.Prog_id == pr.Prog_id && t.year_id=yg.year_id).Count().ToString() + ",";

Errors:
Cannot convert lambda expression to type 'string' because it is not a delegate type
Delegate 'System.Func<webapplication1.std_info,int,bool>' does not take 1 arguments
Operator '&&' cannot be applied to operands of type 'bool' and 'int?'
Posted
Updated 9-May-16 0:44am
v2

1 solution

A tinny syntax error there:
C#
(t => t.Catg_id == ct.Catg_id && t.Prog_id == pr.Prog_id && t.year_id = yg.year_id)

Look at the last part of your condition...
C#
t.year_id = yg.year_id

It should be of course
C#
t.year_id == yg.year_id
 
Share this answer
 
Comments
Karthik_Mahalingam 9-May-16 6:48am    
5good catch
Kornfeld Eliyahu Peter 9-May-16 6:52am    
Thank you...
super_user 9-May-16 6:51am    
OH HO .... thanku ;)
Kornfeld Eliyahu Peter 9-May-16 6:52am    
Exactly... :-)
Sergey Alexandrovich Kryukov 9-May-16 10:23am    
Good catch, a 5.
—SA

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