This is a migrated thread and some comments may be shown as answers.

[Solved] Compiler Error Message: CS0136

1 Answer 148 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Varghese
Top achievements
Rank 1
Varghese asked on 13 Dec 2011, 08:50 PM

I have the following panel bar. When I run this I get the following error at the line where it has subItem.Add().Text("CC").Content(

Compiler Error Message: CS0136: A local variable named 'item' cannot be declared in this scope because it would give a different meaning to 'item', which is already used in a 'parent or current' scope to denote something else


Here is the code I have:

@(Html.Telerik().PanelBar().Name("PanelBar").HtmlAttributes(new { style = "border-radius: 5px;"}).Items(item =>
    {
        item.Add().Text("A").Items(subItem =>
            {
                subItem.Add().Text("AA");
            });

        item.Add().Text("B").Items(subItem =>
            {
                subItem.Add().Text("BB");
            });

        item.Add().Text("C").Items(subItem =>
            {
                subItem.Add().Text("CC").Content(
                        @<text>
                            graph chart data
                        </text>).Action("...", ".");
                subItem.Add().Text("CCC").Action("...", "...");
            });
    }
    ))

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 16 Dec 2011, 12:11 PM
Hi Varghese,

The local variable which is specified in the error is the Razor's item. It is added to the scope when you open the text tag. To avoid the error, you should rename the Lambda expression item parameter.

Greetings,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
Tags
PanelBar
Asked by
Varghese
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or