Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trouble with dataviews
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Trouble with dataviews
Environment versions
Environment:
C# 2.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01343420
Message ID:
01343420
Views:
59
Kevin,

I never heard back from you about setting the sort order to something other than the column field when the user clicks on a grid's column heading. For example, a user might click on the last name column and I want the sort order to be last name + first name. Did my question make sense? Is it possible to do what I want to do?

I can't find any place to put that code and haven't gotten any responses from anyone else either.

In the meantime, I'm trying something that I thought would be a straightforward use of the dataview. I created an mmDataSet for which I needed the last X rows of the table. In order to do that, in SQL I sorted the table by the key field in descending order and just took the TOP X rows. That part works fine. In the MM business object, I gave that dataset it's own table name. Then I added the HookPostGetData and set up a DataView for just that table, which is supposed to sort the table in ascending order on the same key field.

In the mmBusinessForm code, I created an mmDataSet pointing to that table but it didn't pick up my dataview. Then I called the GetDataView method of the mmDataSet to get the dataview in ascending order. The data is still displayed in descending order.

Here's the code I have:
        //Create the data set for 1st or last half of table
        public mmDataSet GetCoverageList(string listHalf)
        {
            string listHalfTable;
            if (listHalf == "A")
                listHalfTable = "CvgCheckListA";
            else
                listHalfTable = "CvgCheckListB";
            mmDataSet ds = (mmDataSet)this.GetDataSet("CoverageTypeSelectByHalf", listHalfTable, this.CreateParameter("@ListHalf", listHalf));
            return ds;
        }

        //HookPostGetData method to set the order for the table CvgCheckListB
        protected override void HookPostGetData()
        {
            if (this.CurrentTableName == "CvgCheckListB")
            {
                mmDataSet ds = (mmDataSet)this.GetCurrentDataSet();
                // Create a custom DataView sorted by date and coverage type
                // Check if the DataView already exists
                DataView dv = (ds.GetDataView("dvCvgCheckListBByType", this.CurrentTableName));
                if (dv == null)
                {
                    dv = new DataView(ds.Tables["CvgCheckListB"]);
                    dv.Sort = "CoverageType asc";
                    ds.AddDataView(dv, "dvCvgCheckListBByType");
                }
                this.StoreDataRow(dv);
            }
        }
In the mmBusinessForm, I have:
            InitializeComponent();
            . . .
            dsCvgCheckListB = this.oCoverageType.GetCoverageList("B");
            dvCvgCheckListB = dsCvgCheckListB.GetDataView("dvCvgCheckListBByType", "CvgCheckListB");
As far as I can tell, I have typed everything in exactly as entered in the DevGuide. What am I missing?

Thanks.
Linda Harmes
HiBit Technologies, Inc.
Reply
Map
View

Click here to load this message in the networking platform