locked
inline editing with the webgrid - checkbox invalid arguments RRS feed

  • Question

  • User379720387 posted

    The error message is on the span class="display-mode".

    How do I find out what these invalid arguments are?

     grid.Column("BillMonthly",
                                style: "col2",
                                format: @<text>
                                    <span class="display-mode">@Html.CheckBox("billmonthly-display", item.BillMonthly, new { disabled = "disabled" })</span>
                                    @Html.CheckBox("BillMonthly", item.BillMonthly, new { @class = "edit-mode" })
                                </text>)

    var billmonthly = tr.find('#BillMonthly').attr('checked') ? true : false;

    '/Methods/ChangeBarn',
                        { OwnerId: ownerid, ProviderId: providerid, StateId: stateid, Zip: zip, Location: location, Address: address, City: city, LName: lname, FName: fname, Email: email, Mobile: mobile, BillMonthly: billmonthly},
                        function (barn) {
                            tr.find('#providerid').text(barn.ProviderId);
                            tr.find('#location').text(barn.Location);
                            tr.find('#address').text(barn.Address);
                            tr.find('#city').text(barn.City);
                            tr.find('#state').text(barn.State);
                            tr.find('#zip').text(barn.Zip);
                            tr.find('#lname').text(barn.LName);
                            tr.find('#fname').text(barn.FName);
                            tr.find('#email').text(barn.Email);
                            tr.find('#mobile').text(barn.Mobile);
                            tr.find('#billmonthly-display').removeAttr("disabled").attr('checked', barn.BillMonthly).attr('disabled', true);
                        }, "json");

    Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: The best overloaded method match for 'System.Web.WebPages.Html.HtmlHelper.CheckBox(string, bool, object)' has some invalid arguments
    
    Source Error:
    
    
    Line 200:                            style: "col2",
    Line 201:                            format: @<text>
    Line 202:                                <span class="display-mode">@Html.CheckBox("billmonthly-display", item.BillMonthly, new { disabled = "disabled" })</span>
    Line 203:                                @Html.CheckBox("BillMonthly", item.BillMonthly, new { @class = "edit-mode" })
    Line 204:                            </text>)
    
    
    Source File: c:\Users\robert\Documents\My Web Sites\billthislive\Members\EditBarns.cshtml    Line: 202
    
    Stack Trace:
    
    
    [RuntimeBinderException: The best overloaded method match for 'System.Web.WebPages.Html.HtmlHelper.CheckBox(string, bool, object)' has some invalid arguments]
       CallSite.Target(Closure , CallSite , HtmlHelper , String , Object , <>f__AnonymousType2`1 ) +193
       System.Dynamic.UpdateDelegates.UpdateAndExecute4(CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3) +738
       CallSite.Target(Closure , CallSite , HtmlHelper , String , Object , <>f__AnonymousType2`1 ) +423
       ASP.<>c__DisplayClass81.<Execute>b__69(TextWriter __razor_template_writer) in c:\Users\robert\Documents\My Web Sites\billthislive\Members\EditBarns.cshtml:202
       System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) +10
       System.Web.Helpers.<>c__DisplayClass10.<Format>b__f(TextWriter tw) +42
       System.Web.WebPages.HelperResult.ToString() +82
       System.Web.Helpers.<>c__DisplayClass4.<Table>b__3(TextWriter __razor_helper_writer) +1444
       System.Web.WebPages.HelperResult.ToString() +82
       System.Web.WebPages.HelperResult.ToHtmlString() +9
       System.Web.HttpUtility.HtmlEncode(Object value) +38
       System.Web.WebPages.WebPageBase.Write(Object value) +68
       ASP._Page_Members_EditBarns_cshtml.Execute() in c:\Users\robert\Documents\My Web Sites\billthislive\Members\EditBarns.cshtml:119
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +197
       System.Web.WebPages.WebPage.ExecutePageHierarchy(IEnumerable`1 executors) +69
       System.Web.WebPages.WebPage.ExecutePageHierarchy() +151
       System.Web.WebPages.StartPage.RunPage() +17
       System.Web.WebPages.StartPage.ExecutePageHierarchy() +62
       System.Web.WebPages.StartPage.RunPage() +17
       System.Web.WebPages.StartPage.ExecutePageHierarchy() +62
       System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
       System.Web.WebPages.WebPageHttpHandler.ProcessRequestInternal(HttpContextBase httpContext) +114
    

    Sunday, November 16, 2014 5:13 PM

Answers

  • User-821857111 posted

    RuntimeBinderException: The best overloaded method match for 'System.Web.WebPages.Html.HtmlHelper.CheckBox(string, bool, object)' has some invalid arguments

    That says that at least one of the parameters you are passing in doesn't fit the required data type. It's looking for a string, a bool and an object. The string and object look fine to me, so that leaves the bool. What data type is BillMonthly in the database?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 17, 2014 2:35 AM

All replies

  • User-821857111 posted

    RuntimeBinderException: The best overloaded method match for 'System.Web.WebPages.Html.HtmlHelper.CheckBox(string, bool, object)' has some invalid arguments

    That says that at least one of the parameters you are passing in doesn't fit the required data type. It's looking for a string, a bool and an object. The string and object look fine to me, so that leaves the bool. What data type is BillMonthly in the database?

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 17, 2014 2:35 AM
  • User379720387 posted

    The datatype is bit., however some of the records are NULL.

    This is the reason!

    Now I get a checkbox when Edit is selected.  What happens after that is a whole new thread.

    P.S. you tutorial code now has a checkbox , which is very helpful, however there is no mention of it on your site.

    Monday, November 17, 2014 8:32 AM
  • User-821857111 posted

    So it's actually a nullable bool. You need to test to see if it has  value:

    item.BillMonthly.HasValue ? item.BillMonthly.Value : false
    Monday, November 17, 2014 8:42 AM