We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridFilterBar and DataTable with foreign keys

Thread ID:





69174 Oct 17,2007 02:43 PM UTC Oct 25,2007 07:26 PM UTC WinForms 1
Tags: Chart
Stephane Dapsanse
Asked On October 17, 2007 02:43 PM UTC

I have a main table that contains columns with foreign keys to other tables.
I display the main table in a GridDataBoundGrid and add a GridFilterBar to it.
I can also display meaningful values (Bonds as as opposed to 3, let's say) in the grid
(instead of the foreign keys) doing:

GridBoundColumnsCollection gbcc = this.thePositionsGrid.Binder.InternalColumns;
gbcc["ProductTypeID"].StyleInfo.CellType = "ComboBox";
gbcc["ProductTypeID"].StyleInfo.DataSource = thePositionsDataController.GetProductTypeTable();
gbcc["ProductTypeID"].StyleInfo.DisplayMember = "ProductTypeName";
gbcc["ProductTypeID"].StyleInfo.ValueMember = "ProductTypeID";
gbcc["ProductTypeID"].StyleInfo.ShowButtons = GridShowButtons.Show;
gbcc["ProductTypeID"].HeaderText = "Type";

At this stage, my GridFilterBar still displays the foreign keys as options for filtering.
The filter still works properly though.
I can display the meaningful values instead by doing:

int col = this.thePositionsGrid.Binder.NameToColIndex("ProductTypeID");
DataTable filterTable = (DataTable) this.thePositionsGrid[1,col].DataSource;
DataTable inputTable = thePositionsDataController.GetProductTypeTable(); // table with related primary keys
int nbrOfRows = filterTable.Rows.Count;
for (int i = 2; i < nbrOfRows;++i)
filterTable.Rows[i][0] = inputTable.Rows[i-2]["ProductTypeName"];

But then the filter is not working properly anymore.

Can you tell the most effective way to display a table with foreign keys in a GridDataBoundGrid,
replace the foreign keys by meaningful values to the user and be able to filter based on these meaningful values?


Rajagopal [Syncfusion]
Replied On October 25, 2007 07:26 PM UTC

Hi Stephane,

You can derive the GridFilterBar and override the WireGrid and GetFilterFromRow to achieve this. Please refer the following sample that helps in doing this.


Let us know if you have any questions.

Thanks for your patience.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon