47
Answers

avoid the duplicate,only once need to display in mvc

vidhya

vidhya

11y
15.5k
1

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)