user3859356
user3859356

Reputation: 739

Order Repeater Databound Item In ascending Order

I have Repetaer with Id rptQuestionbank. I tried it to Use orderby property but I always get some syntax error. I just want to Order the RptQuestionbank.DataSource in ascending order. please help M new to LINQ Please tell me good link to where i can study these basic skills.

public void bindDetails()
{
    using (var surveykshanentities = new SurveyKshanEntities())
    {
        int SessionId = Convert.ToInt16(Session["SurveyId"]);
        RptQuestionbank.DataSource = surveykshanentities.SurveyKshan_QuestionBank
            .Where(x => !surveykshanentities.SurveyKshan_SurveyQuestion.Any(y => 
                y.QuestionId == x.QuestionId && 
                y.SurveyId == SessionId))
            .ToList();
        RptQuestionbank.DataBind();
    }
}

Upvotes: 0

Views: 58

Answers (1)

user3859356
user3859356

Reputation: 739

Finally I After so many hit and trial I did it on my own.

RptQuestionbank.DataSource = 
    surveykshanentities.SurveyKshan_QuestionBank
        .Where(x => !surveykshanentities.SurveyKshan_SurveyQuestion.Any(y => 
            y.QuestionId == x.QuestionId && 
            y.SurveyId == SessionId))
        .ToList()
        .OrderByDescending(p => p.QuestionText);

Upvotes: 1

Related Questions