我有一个绑定到linqdatasource的下拉列表。由于我要排序的字段是一个仅包含数字的varchar,因此我想将其转换为整数以进行排序。 为此,我设置了orderby属性,如下面的代码所示。
<asp:LinqDataSourceID="linqSource" runat="server" ContextTypeName="mydatacontext" EntityTypeName="" TableName="mytablename" OrderBy="cast(myfieldname as int)" Select="new (myfieldname)">
</asp:LinqDataSource>
但是,当我这样做时,会出现以下异常:
[ParseException:“)” oder“,” erwartet。]
System.Web.Query.Dynamic.ExpressionParser.ParseArgumentList()+148
System.Web.Query.Dynamic.ExpressionParser.ParseMemberAccess(Type type, 表达式实例)+184
System.Web.Query.Dynamic.ExpressionParser.ParseIdentifier()+384
System.Web.Query.Dynamic.ExpressionParser.ParsePrimaryStart()+31
System.Web.Query.Dynamic.ExpressionParser.ParsePrimary()+14
System.Web.Query.Dynamic.ExpressionParser.ParseUnary()+260
System.Web.Query.Dynamic.ExpressionParser.ParseMultiplicative()+26
System.Web.Query.Dynamic.ExpressionParser.ParseAdditive()+25
System.Web.Query.Dynamic.ExpressionParser.ParseComparison()+26
System.Web.Query.Dynamic.ExpressionParser.ParseLogicalAnd()+26
System.Web.Query.Dynamic.ExpressionParser.ParseLogicalOr()+26
System.Web.Query.Dynamic.ExpressionParser.ParseExpression()+23
System.Web.Query.Dynamic.ExpressionParser.ParseOrdering()+37
System.Web.Query.Dynamic.DynamicQueryable.OrderBy(IQueryable源, 字符串排序,Object []值)+133
System.Web.UI.WebControls.DynamicQueryableWrapper.OrderBy(IQueryable 源,字符串排序,Object []值)+15
System.Web.UI.WebControls.QueryableDataSourceView.ExecuteQueryExpressions(IQueryable 源,QueryContext上下文)+421
System.Web.UI.WebControls.QueryableDataSourceView.ExecuteQuery(IQueryable 来源,QueryContext上下文)+22
System.Web.UI.WebControls.LinqDataSourceView.ExecuteSelect(DataSourceSelectArguments 参数)+341
System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e)+278 System.Web.UI.WebControls.ListControl.PerformSelect()+37
System.Web.UI.WebControls.BaseDataBoundControl.DataBind()+74
System.Web.UI.Control.DataBindChildren()+185
System.Web.UI.Control.DataBind(布尔iseonOnDataBinding)+160
DevExpress.Web.GridBaseTemplateContainer.DataBind()+21
DevExpress.Web.ASPxWebControlBase.DataBindContainers(控件父级, 布尔值bindContents,布尔值bindTemplates)+164
DevExpress.Web.ASPxWebControlBase.DataBindContainers(控件父级, 布尔值bindContents,布尔值bindTemplates)+222
DevExpress.Web.ASPxWebControlBase.DataBindContainers(控件父级, 布尔值bindContents,布尔值bindTemplates)+222
DevExpress.Web.ASPxWebControlBase.DataBindContainers(控件父级, 布尔值bindContents,布尔值bindTemplates)+222
DevExpress.Web.ASPxWebControlBase.DataBindContainers(控件父级, 布尔值bindContents,布尔值bindTemplates)+222
DevExpress.Web.ASPxWebControlBase.DataBindContainers(控件父级, 布尔值bindContents,布尔值bindTemplates)+222
DevExpress.Web.ASPxWebControlBase.DataBindContainers(控件父级, 布尔值bindContents,布尔值bindTemplates)+222
DevExpress.Web.ASPxWebControlBase.DataBindContainers(控件父级, 布尔值bindContents,布尔值bindTemplates)+222
DevExpress.Web.ASPxWebControlBase.DataBindContainers(控件父级, 布尔值bindContents,布尔值bindTemplates)+222
DevExpress.Web.ASPxWebControlBase.DataBindContainers(控件父级, 布尔值bindContents,布尔值bindTemplates)+222
DevExpress.Web.ASPxDataWebControlBase.DataBindInternal()+152
DevExpress.Web.ASPxWebControl.DataBind()+37
DevExpress.Web.Internal.DataHelperBase.EnsureDataBound(布尔 sureChildControls)+59
DevExpress.Web.Internal.DataContainer.EnsureDataBound()+135
DevExpress.Web.ASPxDataWebControlBase.OnPreRender(EventArgs e)+21
System.Web.UI.Control.PreRenderRecursiveInternal()+88
System.Web.UI.Control.PreRenderRecursiveInternal()+160
System.Web.UI.Control.PreRenderRecursiveInternal()+160
System.Web.UI.Control.PreRenderRecursiveInternal()+160
System.Web.UI.Control.PreRenderRecursiveInternal()+160
System.Web.UI.Control.PreRenderRecursiveInternal()+160
System.Web.UI.Control.PreRenderRecursiveInternal()+160
System.Web.UI.Control.PreRenderRecursiveInternal()+160
System.Web.UI.Control.PreRenderRecursiveInternal()+160
System.Web.UI.Control.PreRenderRecursiveInternal()+160
System.Web.UI.Control.PreRenderRecursiveInternal()+160
System.Web.UI.Page.ProcessRequestMain(布尔 includeStagesBeforeAsyncPoint,布尔值includeStagesAfterAsyncPoint) +883