I'm trying to 'functionalize' the process of creating a bunch of divs to clean up my code.
Here's what I'm trying to do:
My program reads in an excel file and splits the lines into lists using ',' as the delimiter. I have a bunch of pages that need to display the same type of information, so I'm trying to write a function instead of having to rewrite the for loop 15-20 times:
@functions {
void returnDrivers(List<string> list, List<string> colors){
for(int i = 1; i < list.Count; i++){
if(list[i] != ""){
@:<div class="multiBreakdowns" id="@colors[i]">@list[i]</div>
}
}
}
}
First error I received was a missing ;
Quote
Compiler Error Message: CS1002: ; expected
Source Error:
Line 126: if(list[i] != ""){
Line 127: @:<div class="multiBreakdowns" id="@colors[i]">@list[i]</div>
Line 128: }
Line 129: }
Line 130: }
Source Error:
Line 126: if(list[i] != ""){
Line 127: @:<div class="multiBreakdowns" id="@colors[i]">@list[i]</div>
Line 128: }
Line 129: }
Line 130: }
So I added it then got this error:
Quote
Compiler Error Message: CS0201: Only assignment, call, increment, decrement, and new object expressions can be used as a statement
Source Error:
Line 77: #line hidden
Line 78:
Line 79: item => new System.Web.WebPages.HelperResult(__razor_template_writer => {
Source Error:
Line 77: #line hidden
Line 78:
Line 79: item => new System.Web.WebPages.HelperResult(__razor_template_writer => {
Any idea what's going on?

New Topic/Question
Reply



MultiQuote


|