locked
HELP -- ORDERBY causes Exception when DataBiniding RRS feed

  • Question

  • User1402743388 posted

    Hi,

    I have a listview and an EntityDatasource. I am perfroming dynamic where clause and I am trying to order by one of the columns. If I add the orderby in the EntityDataSource or  during "Selecting", page crashes when it tries to bind thelistview. Any ideas what is wrong? I am showing the code below with order by commeneted out.

    protected void EDS_ProductsByCategory_Selecting(object sender, EntityDataSourceSelectingEventArgs e)
            {
                string query= "it.Available=true ";
                 if (Request.QueryString["Style"] != null)
                 query += "and it.Style='" + Request.QueryString["Style"].ToString() + "'";
    
                 //***If I uncomment this line databinding crashes otherwise it works!!!!
                 //e.DataSource.OrderBy = "it.unitcost";
    
    
                e.DataSource.Where = query; 
                   
            }


     

    Tuesday, December 21, 2010 10:10 PM

All replies

  • User-606763320 posted

    Can you post the exception or the stack trace. I have an idea but I would like to see where it errors out at.

    Thank you 

     

    If it.unitcost 

    it is the datacontext then there should not be quotes around it

    Wednesday, December 22, 2010 12:11 AM
  • User1402743388 posted
    [NullReferenceException: Object reference not set to an instance of an object.]
       ASP.productslist_aspx.__DataBind__control16(Object sender, EventArgs e) in c:\works\ProductsList.aspx:25
       System.Web.UI.Control.OnDataBinding(EventArgs e) +91
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +92
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.Control.DataBindChildren() +201
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.Control.DataBindChildren() +201
       System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +101
       System.Web.UI.Control.DataBind() +15
       System.Web.UI.WebControls.ListView.CreateItemsInGroups(ListViewPagedDataSource dataSource, Boolean dataBinding, InsertItemPosition insertPosition, ArrayList keyArray) +1133
       System.Web.UI.WebControls.ListView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +754
       System.Web.UI.WebControls.ListView.PerformDataBinding(IEnumerable data) +44
       System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +128
       System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +33
       System.Web.UI.WebControls.DataBoundControl.PerformSelect() +143
       System.Web.UI.WebControls.ListView.PerformSelect() +113
       System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +74
       ORWWEB.ProductsList.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\mhariri\Desktop\ORWWEB\TailspinSpyworks\ProductsList.aspx.cs:16
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
       System.Web.UI.Control.OnLoad(EventArgs e) +91
       System.Web.UI.Control.LoadRecursive() +74
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
    


     

    Wednesday, December 22, 2010 7:56 AM