wsyeager Posted May 24, 2004 Posted May 24, 2004 I cannot get a dataview to sort at all based on the column name! Here is the following code that I'm using: <code> lstReturnContact.DataSource = dsRolodexXSD.CONTACTS.Select(dsRolodexXSD.CONTACTS.Columns(1).ToString & " <> ''") lstReturnContact.ValueMember = dsRolodexXSD.CONTACTS.Columns(0).ToString lstReturnContact.DisplayMember = dsRolodexXSD.CONTACTS.Columns(1).ToString dvFrAddr.Table = dsRolodexXSD.CONTACTS dvFrAddr.Sort = dsRolodexXSD.CONTACTS.Columns(1).ToString </code> The dsRolodexXSD.CONTACTS.Columns(1).ToString contains the value "CONTACTNAME". I even try putting the string in manually (just "CONTACTNAME"), but it still doesn't work. I'm not getting an error. The listbox comes up fine with the data, but it is not sorted at all. If the sort method couldn't find the columnname, I would get an error. Why is this not sorting??? Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
*Experts* Nerseus Posted May 24, 2004 *Experts* Posted May 24, 2004 What is dvFrAddr? It "looks" like a DataView, but you're not binding to it... Why not just use the listbox's Sorted property? -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
wsyeager Posted May 25, 2004 Author Posted May 25, 2004 I had some of the statements reversed. I should have the datasource after the dataview..... Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
*Experts* Nerseus Posted May 25, 2004 *Experts* Posted May 25, 2004 Did the Listbox's Sorted property do what you want? Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
wsyeager Posted May 26, 2004 Author Posted May 26, 2004 You can't specify the sort property for the listbox when a datasource is present for that type of control. I solved it by sorting the datatable and eliminating the view. Quote Thanks, Bill Yeager (MCP, BCIP) Microsoft Certified Professional Brainbench Certified Internet Professional, .Net Programmer, Computer Programmer YeagerTech Consulting, Inc.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.