The current examples of creating WebGrids all use "mickey-mouse"scenarios with adding columns and rows manually - hardly realistic. Does anybody have experience of populating a databound grid programmatically? I am doing this to try and curcumvent some issues that I am experiencing with WebGrid.
To start with, I have a Webgrid on a web page thst is minimalist:
<igtbl:UltraWebGrid ID="ProjectAssetList" runat="server"></igtbl:UltraWebGrid>
On the page load event I do the following to the Grid:
To mimic the declarative structure (where Columns are always declared within bands) I create an UltraGridBand object and assign its properties:
Then I add Columns to the Band object. For each UltraGridColumn I set the following:
Finally, I append the Band to the grid and perform a Databind.
I get a "No Data To Display" message.
Any ideas as to what I am missing?
I could supply the source code for this but it is picking-up data from database tables so I thought the explanation above would be clearer.
VS 2008 Pro, IG 2008v1, C#.
Kind regards
Paul
PaulShearing said:Does anybody have experience of populating a databound grid programmatically? I am doing this to try and curcumvent some issues that I am experiencing with WebGrid.
Sounds like doing it the hard way to me. What "issues"?
PaulShearing said: I could supply the source code for this but it is picking-up data from database tables so I thought the explanation above would be clearer.
The code might help us spot the problem. (I've never attempted what you're doing, so I've got my doubts, but I'll be happy to try.)
DataBinding works when you set the Grid.DataSource [http://help.infragistics.com/Help/NetAdvantage/NET/2007.2/CLR2.0/html/Infragistics2.WebUI.UltraWebGrid.v7.2~Infragistics.WebUI.UltraWebGrid.UltraWebGrid~DataBind.html]
So if you're adding bands, columns and rows manually, you shouldn't perform any databinding since the grid will try to load data from the assigned datasource, in this case none. I guess that's why you get the 'No data to display' alert.