Most of my CSLA experience was with CSLA 1.52 in .NET 2.0. I was able to sort data from my business collections in the datagridview without any problem. How do I do that with CSLA 2.0? Basically the grids don't allow me to click on the column header, it makes me think there is something else I need to do.
2 steps are required.
1. Enable sorting on the grid. right click / Edit Columns on the grid, pick the column and change SortMode to "Automatic".
2. Provide a sorted binding source. Like this:
MyBusinessObjectList list = MyBusinessObjectList.GetList();
Csla.SortedBindingList<BusinessObjectInList> sortedList = new Csla.SortedBindingList<BusinessObjectInList>(list);
sortedList.ApplySort("PropertyToSortOn", listSortDirection.Ascending);
myBindingSource.DataSource = sortedList;
Hi,
I also have problems sorting. I looked for the SortMode property but it isn'y available in the GUI nor in code. Is this a property for WinForm only? I have my grid on a web form and the sort isn't getting applied correctly.
Dim list As ContactList = ContactList.GetContactListsorted.ApplySort(
"fname", ListSortDirection.Ascending)e.BusinessObject = sorted
Am I missing something here?
6/13/06 - revelation
FYI, column names are case sensitive AS DEFINED in the BO, not in the table. Should have known this but learned the hard way.
Once implemented, I also learned that since I really need to sort on 2 columns, this isn't going to be the best method!
hi,
I am trying to bind a namevalue pair from a namevaluelist base to gridview and binding event is calling rowdatabound event but unable to find the name value class there please help.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'NameValuePair[System.Guid,System.String]' to type 'Csla.NameValueListBase`2[System.Guid,System.String]'.
Source Error:
Line 75: if (e.Row.RowType == DataControlRowType.DataRow)
Line 76: {
Line 77: NameValueListBase<Guid, string> drview = (NameValueListBase<Guid, string>)e.Row.DataItem;
Line 78: //NameValueConfigurationCollection drview = (NameValueConfigurationCollection)e.Row.DataItem;
Line 79: CheckBox chkSelected = new CheckBox();
Source File: D:\UTCWebApp\UTCWebApp\Default.aspx.cs Line: 77
Stack Trace:
[InvalidCastException: Unable to cast object of type 'NameValuePair[System.Guid,System.String]' to type 'Csla.NameValueListBase`2[System.Guid,System.String]'.]
UTCWebApp._Default.gvPrivilegeList_RowDataBound(Object sender, GridViewRowEventArgs e) in D:\UTCWebApp\UTCWebApp\Default.aspx.cs:77
System.Web.UI.WebControls.GridView.OnRowDataBound(GridViewRowEventArgs e) +96
System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) +211
System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +4310
System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +89
System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +38
System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +126
System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +98
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +153
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +99
System.Web.UI.WebControls.GridView.DataBind() +23
UTCWebApp._Default.FillRoleList() in D:\UTCWebApp\UTCWebApp\Default.aspx.cs:56
UTCWebApp._Default.Page_Load(Object sender, EventArgs e) in D:\UTCWebApp\UTCWebApp\Default.aspx.cs:24
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +31
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +68
System.Web.UI.Control.OnLoad(EventArgs e) +88
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3036
Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832
NameValueListBase<Guid, string> drview = (NameValueListBase<Guid, string>)e.Row.DataItem;
The row's DataItem will be of NameValuePair[System.Guid,System.String], not NameValueListBase.
HTH
Andy
Copyright (c) Marimer LLC