vidhya

vidhya

  • NA
  • 324
  • 88.5k

avoid the duplicate,only once need to display in mvc

Jul 31 2013 8:37 AM

I need to display the testname, if the testname repeats i need not to avoid it? 
i used like this but duplicate is displaying.

@{
  var tname="null" ;
           
  }
  @foreach (StudentGradeBook x in Model.Student)
                   {
                     
                       if(!(tname.Equals(@x.TestName)))
                       {
                       <th>@x.TestName</th>
                       }
                       tname = @x.TestName.ToString();
                   }

If x contains
test
test
test
testing
testing

But i need to display

test
testing

Answers (47)