订单转发器数据绑定项目按升序排列

时间:2014-09-09 04:55:53

标签: asp.net linq entity

我有Id rptQuestionbank的Repetaer。我尝试使用orderby属性,但我总是得到一些语法错误。我只想按升序排序RptQuestionbank.DataSource。 请帮助M新来LINQ 请告诉我在哪里可以学习这些基本技能的良好链接。

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();
    }
}

1 个答案:

答案 0 :(得分:1)

最后我经过如此多的打击和试验,我自己做了。

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