This project is read-only.

How to set a column title dynaically

Jul 10, 2013 at 1:15 PM

How can I set the title of a column dynamically? I've set the text for the title in a viewbag object in the controller but trying to access the viewbag from within the grid call causes the following error:

"CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type"

my code:
                    .RenderValueAs(c => Html.CheckBox("cbIP1_"+c.ProductCode, c.isInPromotion1).ToHtmlString());
                    columns.Add(c => c.isInPromotion1)
the error occurs on the rendervalueas line...

Thanks for any help!

Jul 10, 2013 at 3:08 PM
ViewBag - it is a dynamic object, you need to case you property to string:
Jul 10, 2013 at 3:22 PM
Hi Bukharin,

Thanks for your reply, I tried that and I still get the same error, any further suggestions?

Jul 10, 2013 at 4:22 PM
Try to cast it explicitly:
Jul 10, 2013 at 4:46 PM
Hi Bukharin,

Thanks! that did it....