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

Dynamically changing the DataSource of a BoundColumn based on the content of a previous column

Thread ID:

Created:

Updated:

Platform:

Replies:

5620 Jul 10,2003 05:11 PM UTC Jul 11,2003 05:16 AM UTC WinForms 1
loading
Tags: EditControl
Steli Andrei
Asked On July 10, 2003 05:11 PM UTC

Hello, I do have a GridDataBoundGrid and I do have two bound columns: CategoryID and PartID and the data source of the PartID column I want to change dynamically based on what I select in the first column. I looks like none of the Events that I've tried: CurrentCellChanged, CurrentCellCloseDropDown. Unless the cell looses the focus, none of these events get triggered. Is there any event that gets triggered after the value gets placed in the cell ?

Administrator [Syncfusion]
Replied On July 11, 2003 05:16 AM UTC

I think CurrentCellChanged is fired at any point the cell value changes. So, it should be fired when you change the cell value even if you do not leave the cell. But you probably will have an easier time if you can do things in the following manner. This assumes that all the values for the PartID are in the same table. The reason this is important is that this allows you to assign a single datasource to the gridboundcolumn.StyleInfo.DataSource as well as a single displaymember and a single valuemember. Then the idea is that when the combobox in the PartID column is dropped, you will create a new dataview on this datatable that is filtered to show exactly the values you want based on the cell value from the other grid column. You do this in CurrentCellShowingDropDown. Here is a little sample.
 
private void gridDataBoundGrid1_CurrentCellShowingDropDown(object sender, GridCurrentCellShowingDropDownEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid.CurrentCell;
	if(cc.ColIndex == 2)
  //column that need to be filtered...
	{
		GridComboBoxCellRenderer cr = cc.Renderer as GridComboBoxCellRenderer;
		if(cr != null)
		{
			DataView dv = new DataView(dataTable1);
			dv.RowFilter = string.Format("[MyCol1] = '{0}'", this.gridDataBoundGrid1[cc.RowIndex, 1].Text);
         		((GridComboBoxListBoxPart)cr.ListBoxPart).DataSource = dv;
		}
	}
}
Now if all the values for the PartID are not from the same table that you can filter to get the correct datasource, then you try to do the same thing, ie. set the new datasource in CurrentCellShowingDropDown, but the may be addition tasks that need to be done to make sure the original cell displays are set up properly. This can require handling Model.QueryCellInfo to dynamically set the cell value for the PartID column. If this is the case, post back explaining where your dynamic datasources come from, and maybe I can suggest something else. You may want to move this discussion from this Edit forum into our Grid forum where other grid users may see it.

CONFIRMATION

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.

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

;