Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm Data Binding / October 2004

Tip: Looking for answers? Try searching our database.

DataGrid: replace foreign key values and use replacements for sort

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Guido Kraus - 05 Oct 2004 20:43 GMT
My DataGrid shows a table 'Orders' which has a foreign key column
'CustomerID'. Instead of displaying the CustomerID I want to display the
customer name.

I accomplished this by creating a 'CustomerNameColumn' which inherits from
'DataGridTextBoxColumn'. Basically, 'CustomerNameColumn' overrides
'GetColumnValueAtRow()' by returning the customer name and not its ID.

My problem: The user wants to sort by 'CustomerNameColumn' and the DataGrid
does not use the displayed values but the underlying foreign key values (i.e.
the CustomerID field). Therefore the user gets unexpected results because the
grid does not sort alphabetically.

Any ideas how to override the grids sorting behavior?

Thanks,
Guido
Kevin Yu [MSFT] - 06 Oct 2004 08:36 GMT
Hi Guido,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to display the CustomerName
instead of CustomerID in the child table. If there is any misunderstanding,
please feel free to let me know.

As far as I know, we can try another way to achieve this. Suppose we are
working on a typed dataset and data relations(CustomersOrders) have been
created.

1. Add a new column named CustomerName in the Orders table.
2. Set the CustomerName.Expression to "Parent(CustomersOrders).CustomerName"

A new column will be added to the Orders table. Its value will be get from
parent table automatically. For more information about expression, please
check the following link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfSystemDataDataColumnClassExpressionTopic.asp

Kevin Yu
Signature

=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Kevin Yu [MSFT] - 08 Oct 2004 09:12 GMT
Hi Guido,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
Signature

=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.