Hi
How to create template columns dynamically?
I am generating my resultset using Pivot sql statement. My query will return different columns everytime it runs. but the number of columns are same(8).
Hence I dont know my column names in advance. So I cannot create bound columns or template columns in design time to bind my dataset to webdatagrid's datasource with Autogeneratecolumns=false.
I need to convert the columns into template columns to show images based on the column value.
Please see the follwoing query and sample output and suggest me in desiging a webdatagrid.
Thanks in advance.
sample query:select Name, [05/31/2012] as [05/31],[06/01/2012] as [06/01],[06/02/2012] as [06/02],[06/03/2012] as [06/03],[06/04/2012] as [06/04],[06/05/2012] as [06/05],[06/06/2012] as [06/06] from(select b.dashboardstatus,a.name,convert(varchar(10),b.scorecarddate,101) as scorecarddate from [_Scorecard].[Processes] a inner join [_Scorecard].[ProcessDailySummary] b on a.processid=b.processid and b.scorecarddate between '04/01/2012' and '06/06/2012')as p PIVOT(sum(dashboardstatus)forscorecarddate in ( [05/31/2012],[06/01/2012],[06/02/2012],[06/03/2012],[06/04/2012],[06/05/2012],[06/06/2012]))as pvt order by pvt.name
Sample Result:
Name 05/31 06/01 06/02 06/03 06/04 06/05 06/06 -- (Columns)Factory Unit Info Import 5 5 NULL NULL 5 5 NULLFactoryProductionControl.DoTheWorkImport 5 5 NULL NULL 5 5 NULLFactoryProductionControl.FactoryProductionImportFile 5 5 NULL NULL 5 5 NULLFactoryProductionControl.FactoryProductionProcessMakeRecords 5 5 NULL NULL 5 5 NULLFactoryProductionControl.TestRecordProcessException NULL NULL NULL NULL NULL NULL 5IDSVerificationControl.IDSVerification 5 5 NULL NULL 5 5 NULLIDSVerificationControl.ShowCompressedData 5 5 NULL NULL 5 5 NULLShippedUnitNotesControl.BuildShippedUnitNotes 2 NULL NULL NULL 3 3 NULLShipUnitsControl.ProcessforCBPClaims 5 5 NULL NULL 5 5 NULLWLCDataBuildControl.SyncShippedUnitsToWLC 5 5 NULL NULL 5 5 NULL
Hello bharat_bachu,
Thank you for posting in the community.
As in your scenario the number of columns may vary I suggest that you refer to the following articles in our doucmentation which illustrate how columns may be added to WebDatagrid dynamically:
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2012.1/CLR4.0/html/WebDataGrid_Add_or_Remove_a_Column.html
http://help.infragistics.com/Help/NetAdvantage/ASPNET/2012.1/CLR4.0/html/WebDataGrid_Using_Item_Template.html
Using the above technique would require some logic to differentiate columns which are to be templated and those which are to be bound.
Please feel free to contact me if you have any questions.
Please contact me if you have any questions regarding this scenario.
Hi Ivanov
i am new to Infragistics controls. Can you show me how to create a dynamic webDataGrid and insert data in webDataGrid's columns and rowss using code behind. Thanks in advance!