Hi
I am trying to bind WHDG to a dataset via code-behind and manual band and column definition.
Everything works fine if I assign and databind once.
However, sometimes I need to bind, then clear and then again bind to a different dataset.
In this case, the rows do not appear and rows.count keeps returning -1.
Have tried various options for clearing the original datasource and it appears that data is indeed cleared.
Pl advise ASAP
Thanks
Hello Even Chen,
Please let me know if you need any further assistance with this matter.
Hello abhisinghal21,
Could you please modify my sample project attached in my previous response to this thread in order to make this issue reproducible?
This is going to be highly appreciated and would help me investigate this matter further.
Thank you for your cooperation on this matter.
Please let me know if you have any additional questions.
I wanted to let you know that we are currently investigating this matter and we will contact you tomorrow with our findings.
Thanks Vasya - Understood this point.
Next question:
I am manually creating bands and columns (autogenerate=false)
Hence, before assigning a new datasource, I intend to call as follows:
oUltra.GridView.Band.Bands.Clear() oUltra.Rows.Clear() oUltra.GridView.Columns.Clear() oUltra.ClearTemplates() oUltra.GridView.ClearDataSource()
However, if I include the Band.Bands.Clear or oultra.bands.clear, a sys.argumentexception is thrown on client side javascript.
If I dont include the band.bands.clear call, the band.bands.count returns 1 even after cleardatasource.
Pl advise
Abhishek
Thank you for getting back to me.
I investgated you requirement further and what I can suggest is DataBinding grid after adding the relation. In this scenario the grid will be bound and rendered with the second data source with the newly added relation. For example:
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load If Not IsPostBack Then Me.WebHierarchicalDataGrid1.DataSource = TestClass.Dataset1 Dim ds As New DataSet() ds = WebHierarchicalDataGrid1.DataSource Dim relation As New DataRelation("IDRelation", ds.Tables(0).Columns("ID"), ds.Tables(1).Columns("ID")) ds.Relations.Add(relation) Me.WebHierarchicalDataGrid1.GridView.ClearDataSource() Me.WebHierarchicalDataGrid1.DataSource = ds Me.WebHierarchicalDataGrid1.GridView.DataBind() End If
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Me.WebHierarchicalDataGrid1.DataSource = TestClass.Dataset1
Dim ds As New DataSet()
ds = WebHierarchicalDataGrid1.DataSource
Dim relation As New DataRelation("IDRelation", ds.Tables(0).Columns("ID"), ds.Tables(1).Columns("ID"))
ds.Relations.Add(relation)
Me.WebHierarchicalDataGrid1.GridView.ClearDataSource()
Me.WebHierarchicalDataGrid1.DataSource = ds
Me.WebHierarchicalDataGrid1.GridView.DataBind()
End If
I am attaching to modified sample for your reference.
Please let me know if you have any further questions regarding this matter