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. Image for the cookie policy date
close icon

GridDataBoundGrid binding event ???

what are the equivalent events for the syncfusion "GridDataBoundGrid". like asp.net datagrid "DataBinding" and "ItemDataBound" events

9 Replies

AD Administrator Syncfusion Team August 13, 2004 09:10 AM UTC

There is a grid.Binder.DataSourceChanged event that is raised when the grid''s datasource changes. I am not sure there is any event similar to ItemDataBound. Exactly what actions are you trying to catch? You can use events directly on the DataSource to catch adding items, columns etc to the data source. These do not depend on the grid. If your datasource is a DataSet/DataTable, then the associated currencymanager has a ListChanged event that gives you access to most of these actions.


KA kalicharan August 13, 2004 09:37 AM UTC

Thanks for your reply. suppose for example my requirement is like this, then which event I have to use. 1. Departments 2. Employees grid.datasource = dataset.tables["dept"]; what I have to do for Employees drop down list Thanks, Kalicharan Boorugu In the grid I have to display the departments in one column employees (drop down list) in another column. I have a Dataset with two tables 1. Depts 2. Employees >There is a grid.Binder.DataSourceChanged event that is raised when the grid''s datasource changes. I am not sure there is any event similar to ItemDataBound. > >Exactly what actions are you trying to catch? > >You can use events directly on the DataSource to catch adding items, columns etc to the data source. These do not depend on the grid. If your datasource is a DataSet/DataTable, then the associated currencymanager has a ListChanged event that gives you access to most of these actions.


AD Administrator Syncfusion Team August 13, 2004 09:57 AM UTC

>>1. Departments 2. Employees grid.datasource = dataset.tables["dept"]; << I assume Departments and Employees are two columns in the DataTable, dataset.tables["dept"]. And that you want to access another table, say dataset.tables["emp"], to provide the droplist to associate a foreign key in the Employees column of the dept table with some display value in the emp table. If so, you need to set the GridBoundColumn associated with the Employees column to use a ComboBox CellType, as well as set its DataSource, ValueMember and DisplayeMember properties so the grid can display the combobox cell showing the foreign key DisplayValues. GridStyleInfo style = this.grid.InternalCOlumns["Employees"].StyleInfo; style.CellType = "COmboBox"; style.DataSource = dataset.tables["emp"]; style.DisplayMember = "SomePropertyInTheEmpTable"; style.ValueMember = "PropetyInTheEmpTableThatMatchesTheValuesInTheDeptTable"; There are samples of such comboboxes in Grid\Samples\DataBound\GDBGcombos. If you are not trying to do a foreign key combobox column, but instead want an hierarchical grid showing a data relation between your dept and your emp table, then you should look at the Grid\Samples\DataBound\Hierarchical\ExpandGrid sample. Normally, you do not need to handle events for either of these tasks (unless you want to customize the default behaviors.)


KA kalicharan August 13, 2004 01:38 PM UTC

Still not working this is the code I am using please check it. DataSet dstOutSchDetails = new DataSet(); dstOutSchDetails = clsSchDataAccess.GetOutboundSchedulerDetails(dtmDate); DataColumn dcSHPShipmentNo = dstOutSchDetails.Tables[0].Columns["strShipmentNo"]; DataColumn dcOrderShipmentNo = dstOutSchDetails.Tables[1].Columns["strShipmentNo"]; dstOutSchDetails.Tables[0].ChildRelations.Add(dcSHPShipmentNo, dcOrderShipmentNo); grdOutboundScheduler.DataSource = dstOutSchDetails.Tables[0]; Syncfusion.Windows.Forms.Grid.GridStyleInfo style = gbcInSchDeliveryNo.StyleInfo; style.DataSource = dstOutSchDetails.Tables[1]; style.DisplayMember = "strOrderNo"; style.ValueMember = "strShipmentNo"; >>>1. Departments >2. Employees > >grid.datasource = dataset.tables["dept"]; ><< > >I assume Departments and Employees are two columns in the DataTable, dataset.tables["dept"]. And that you want to access another table, say dataset.tables["emp"], to provide the droplist to associate a foreign key in the Employees column of the dept table with some display value in the emp table. If so, you need to set the GridBoundColumn associated with the Employees column to use a ComboBox CellType, as well as set its DataSource, ValueMember and DisplayeMember properties so the grid can display the combobox cell showing the foreign key DisplayValues. > > >GridStyleInfo style = this.grid.InternalCOlumns["Employees"].StyleInfo; >style.CellType = "COmboBox"; >style.DataSource = dataset.tables["emp"]; >style.DisplayMember = "SomePropertyInTheEmpTable"; >style.ValueMember = "PropetyInTheEmpTableThatMatchesTheValuesInTheDeptTable"; > > >There are samples of such comboboxes in Grid\Samples\DataBound\GDBGcombos. > >If you are not trying to do a foreign key combobox column, but instead want an hierarchical grid showing a data relation between your dept and your emp table, then you should look at the Grid\Samples\DataBound\Hierarchical\ExpandGrid sample. > >Normally, you do not need to handle events for either of these tasks (unless you want to customize the default behaviors.)


AD Administrator Syncfusion Team August 13, 2004 01:53 PM UTC

Try commenting out these lines. DataColumn dcSHPShipmentNo = dstOutSchDetails.Tables[0].Columns["strShipmentNo"]; DataColumn dcOrderShipmentNo = dstOutSchDetails.Tables[1].Columns["strShipmentNo"]; dstOutSchDetails.Tables[0].ChildRelations.Add(dcSHPShipmentNo, dcOrderShipmentNo); There is no need for any kibnd of relation here unless you are trying to use a Hierarchial grid, in which case, there woul dbe no combobox involved. If you want an hiearchical grid, look at teh ExpandGrid sample and set thisng up that way. (No ChildRelations, add teh releation directly to teh dataset.Relations collection as in that sample.) If you are trying to use a combobox and not an hierarchical grid (showing related tables), other things to check are that strShipmentNo should be the exact (case counts) column names for columns in both table0 and table1. Also, strOrderNo must be a column in table1.


KA kalicharan August 13, 2004 02:40 PM UTC

Thanks for the early reply, I got the dropdownvalues but not displaying the values according to the relationship. Displaying all the orderno''s irrespective of shipmentno check the code once again please. dstOutSchDetails = clsSchDataAccess.GetOutboundSchedulerDetails(dtmDate); grdOutboundScheduler.DataSource = dstOutSchDetails.Tables[0]; GridStyleInfo style = grdOutboundScheduler.Binder.InternalColumns[2].StyleInfo; style.CellType = "ComboBox"; style.DropDownStyle = GridDropDownStyle.AutoComplete; style.DataSource = dstOutSchDetails.Tables[1]; style.DisplayMember = "strOrderNo"; style.ValueMember = "strShipmentNo"; >Try commenting out these lines. > > >DataColumn dcSHPShipmentNo = dstOutSchDetails.Tables[0].Columns["strShipmentNo"]; >DataColumn dcOrderShipmentNo = dstOutSchDetails.Tables[1].Columns["strShipmentNo"]; >dstOutSchDetails.Tables[0].ChildRelations.Add(dcSHPShipmentNo, dcOrderShipmentNo); > > >There is no need for any kibnd of relation here unless you are trying to use a Hierarchial grid, in which case, there woul dbe no combobox involved. If you want an hiearchical grid, look at teh ExpandGrid sample and set thisng up that way. (No ChildRelations, add teh releation directly to teh dataset.Relations collection as in that sample.) > >If you are trying to use a combobox and not an hierarchical grid (showing related tables), other things to check are that strShipmentNo should be the exact (case counts) column names for columns in both table0 and table1. Also, strOrderNo must be a column in table1.


AD Administrator Syncfusion Team August 13, 2004 02:57 PM UTC

If you want the DropDown to vary by order number, you will probably have to handle CurrentCellShowingDropDown and do the work there. Here is a KB link discussing how you might do it. http://www.syncfusion.com/Support/article.aspx?id=567


KA kalicharan August 13, 2004 04:35 PM UTC

Thanks a lot, Is there any event just like asp.net datagrid ItemDatabound for sync grid. Thanks, Kalicharan Boorugu. >If you want the DropDown to vary by order number, you will probably have to handle CurrentCellShowingDropDown and do the work there. Here is a KB link discussing how you might do it. > >http://www.syncfusion.com/Support/article.aspx?id=567


AD Administrator Syncfusion Team August 13, 2004 05:34 PM UTC

I do not know the purpose/use of the ItemDataBound event you mentioned. If you will explain the action you are trying, maybe I can suggest an event. As far as a dynamic event, grid.Model.QueryCellInfo is fired anytime the grid needs a value for the cell at e.RowIndex and e.ColIndex. The proposed GridStyleInfo object for the cell is in e.Style. At this point, you can modifty any property in the e.Style object to affect the cell value, look or other properties on a JUST-IN-TIME basis. In this manner, you can make the grid completely dynamic.

Loader.
Live Chat Icon For mobile
Up arrow icon