i used like this but duplicate is displaying.
@{
var tname="null" ;
}
@foreach (StudentGradeBook x in Model.Student)
{
if(!(tname.Equals(@x.TestName)))
{
}
tname = @x.TestName.ToString();
}
If x contains
test
test
test
testing
testing
But i need to display
test
testing
Shakil Ahmed51 reputationPosted Nov 18, 2017, 1:49 AM EST
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 31, 2013, 4:42 AM EDT
Try like this
@{
var tname="" ;
}
@foreach (StudentGradeBook x in Model.Student)
{
if(!(tname.Equals(@x.TestName)))
{
}
tname = @x.TestName.ToString();
}
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 31, 2013, 4:44 AM EDT
we can use list in view class?
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 31, 2013, 4:45 AM EDT
@{
var tname="" ;
}
@foreach (StudentGradeBook x in Model.Student)
{
if(tname!=@x.TestName.ToString())
{
}
tname = @x.TestName.ToString();
}
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 31, 2013, 4:49 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 31, 2013, 7:54 AM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 31, 2013, 7:56 PM EDT
test
test
test
testing
testing
@tname displays
test
test
testing
testing
test
@x.TestName
test
test
testing
testing
test
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 31, 2013, 8:16 PM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 31, 2013, 8:19 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 31, 2013, 8:33 PM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 31, 2013, 8:39 PM EDT
vidhyaRank #4,868 · 321 reputationPosted Jul 31, 2013, 8:40 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 31, 2013, 8:53 PM EDT
try like this
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 31, 2013, 9:08 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 31, 2013, 9:11 PM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 31, 2013, 9:49 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 31, 2013, 10:07 PM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 31, 2013, 10:24 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 31, 2013, 10:34 PM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 31, 2013, 10:50 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 31, 2013, 11:05 PM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Jul 31, 2013, 11:13 PM EDT
test
test
test
testing
testing
@x.TestName displays like this
test
test
testing
testing
test
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 31, 2013, 11:18 PM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Aug 1, 2013, 1:04 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 1, 2013, 1:19 AM EDT
the output should be?
test
testing
pretest
prestest
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Aug 1, 2013, 1:21 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 1, 2013, 1:23 AM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Aug 1, 2013, 1:51 AM EDT
var j = 0;
For testname it work fine, same i tried for total points i does not work. y?
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 1, 2013, 1:57 AM EDT
var arrayPoints = new string[Model.Student.Count];
var j = 0;
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Aug 1, 2013, 2:03 AM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Aug 1, 2013, 2:11 AM EDT
Regards,
Iftikar
vidhyaRank #4,868 · 321 reputationPosted Aug 1, 2013, 2:15 AM EDT
Sunny SharmaRank #223 · 11.1K reputationPosted Aug 1, 2013, 2:19 AM EDT
I have the solution for you, modify your view as following:
----------------------------
@model MavinLMSService.ViewModels.Professor.GradeBook.IndexModel
@{
ViewBag.Title = "Grade Book";
Layout = "~/Views/Shared/_PrimaryLayout.cshtml";
}
{
}
-------------------------------------------------------------
Yes, there's one catch also. You need to import the namespace into your view by adding @using System.Data.Linq at the top of your view. However if you want it in all your views then you need to add
Feedback awaited.
Cheers!
vidhyaRank #4,868 · 321 reputationPosted Aug 1, 2013, 2:28 AM EDT
I am getting error
The name X does not contain in the current content
Then i changed like this
now its work fine.
Sunny SharmaRank #223 · 11.1K reputationPosted Aug 1, 2013, 2:32 AM EDT
use tName instead of x.Testname:
----------------------
{
}
--------------------------------------
vidhyaRank #4,868 · 321 reputationPosted Aug 1, 2013, 2:39 AM EDT
I need to display the total of totalpoints and pointspossible in the before column. how to add it?
Sunny SharmaRank #223 · 11.1K reputationPosted Aug 1, 2013, 2:45 AM EDT
vidhyaRank #4,868 · 321 reputationPosted Aug 1, 2013, 2:53 AM EDT
Before sample assignment the heading is totalpoints the corresponding row i need to add the points and display there. pointspossible and totalpoints are displayed in 2nd row
vidhyaRank #4,868 · 321 reputationPosted Aug 1, 2013, 3:04 AM EDT
I need to change the 1st for loop like the 2nd for loop how can i change, 1st loop contains 2 fields.
Sunny SharmaRank #223 · 11.1K reputationPosted Aug 1, 2013, 3:26 AM EDT
use the code below:
{
}
{
@ var tPoints = (from gradeBook in Model.Student where gradeBook.TestName==tName.ToString() select gradeBook.TotalPoints).sum();
@ var pointsPossible = (from gradeBook in Model.Student where gradeBook.TestName==tName.ToString() select gradeBook.PointsPossible).sum();
}
-------------------------------------------
Sunny SharmaRank #223 · 11.1K reputationPosted Aug 1, 2013, 3:49 AM EDT
vidhyaRank #4,868 · 321 reputationPosted Aug 1, 2013, 3:58 AM EDT
{
@ var tPoints = (from gradeBook in Model.Student where gradeBook.TestName==tName.ToString() select gradeBook.TotalPoints).sum();
@ var pointsPossible = (from gradeBook in Model.Student where gradeBook.TestName==tName.ToString() select gradeBook.PointsPossible).sum();
}
I get TotalPoints from testname according to the this
I get PointsPossible from assignmentname according to this.
Sunny SharmaRank #223 · 11.1K reputationPosted Aug 1, 2013, 4:01 AM EDT
vidhyaRank #4,868 · 321 reputationPosted Aug 1, 2013, 4:09 AM EDT
totalpoints is displayed/entered according to the testname,
pointspossible is displayed/entered according to the assignmentname.
then how is it possible to use like this
@foreach(var tName in (from gradeBook in Model.Student select gradeBook.TestName).Distinct())
{
}
Sunny SharmaRank #223 · 11.1K reputationPosted Aug 1, 2013, 4:12 AM EDT
vidhyaRank #4,868 · 321 reputationPosted Aug 1, 2013, 4:15 AM EDT
i think , dont want to waste yr time.
Sunny SharmaRank #223 · 11.1K reputationPosted Aug 1, 2013, 4:19 AM EDT
Cheer up!
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts