SinceForever
SinceForever

Reputation: 232

. NET Overload method has invalid arguments

I am trying to generate a datatable based on the names that are put in the txt boxes that are associated with the button mentioned below. However I am getting ann error where the datatable is being created.

Error:

The best overloaded method match for 'MSafety.InsReport.ConvertToDTForInstructors(System.Collections.Generic.List)' has some invalid arguments

Code:

    protected void btnInsName_Click(object sender, EventArgs e)
    {
        try
        {

            DataTable dt = new DataTable();

            var wingsList = context.Wings.Where(row => row.Enabled == 1).ToList();

            DataTable dtDDL = new DataTable();

            dtDDL = ConvertToDTForWings(wingsList);
            ddlWing.DataSource = dtDDL;
            ddlWing.DataBind();

            var result = context.GetActiveInstructorsByLastName(txtLastName.Text,txtFirstName.Text).ToList();

            dt =ConvertToDTForInstructors(result);

            rptInsReport.DataSource = dt;

            rptInsReport.DataBind();

            ViewState["ReportDataSource"] = dt;

            if (result.Count != 0)
            {
                PrintButtons("YES");
            }
            else
            {
                PrintButtons("NO");
            }
        }
        catch (EntityException ex)
        {
            NtfyObject.ServerError(Page);
        }

        rptInsReport.Visible = true;
    }

Upvotes: 0

Views: 125

Answers (1)

nanny
nanny

Reputation: 1108

Check the type of result as it gets passed in to ConvertToDTForIntructors(). I'm betting ToList() is returning an ArrayList or another non-generic list.

As you can see by the error, ConvertToDTForInstructors() needs a generic List<>.

Check out this answer: .NET Casting Generic List for info on casting to a generic List<>.

Upvotes: 1

Related Questions