We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

CellsWebGrid not cleared between databinds

I have the very simple code below which should allow me to select a customer from a drop down list and disply the associated spreadsheet in a CellsWebGrid.

However, data from the previous customer is displayed amongst the data from the most recently selected customer. i.e. data is not cleared before databinding.

Protected Sub acbxCustomer1_DataChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles acbxCustomer1.DataChanged

Try

GridWeb1.WebWorksheets.ImportExcelFile("c:\Data\Utilisation for " & acbxCustomer1.A_Text & “.xlsx”)
GridWeb1.DataBind()

Catch ex As Exception
Message(“Exception in acbxCustomer1_DataChanged”)
Message(ex.Message)
End Try

What is happening here? Is there something more that databind which is required to do a standard databind?

Regards

Richard


End Sub

Hi,


Please see the demos on how you can use or work with Data Binding:

You cannot just load the Excel file and implement data bind feature. Data Binding works differently. See the above demos for your reference.

Also check the articles for your reference about data binding:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/data-binding-1.html

Thank you.



I have read the articles and demos that you pointed me to.

You documentation also points to a much easier way of addressing the problem of databinding (importing) a spreadsheet at runtime. You can find this at:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/opening-an-ms-excel-file.html

According to my reading of the information provided there all I have to do is
GridWeb1.WebWorksheets.ImportExcelFile(“filename”)

It appears to work just like the documentation suggest with the execption of loading the data for a second customer. When this problem appeared I added the “dataBind” as that would be a pretty normal .net approach.

So, using the documented “importExcelFile” how do I clear the data from the previous load?

Many thanks

Richard




Hi,


Well, I am not sure about your requirement, but I think you may try WebWorksheets.Clear() method to clear the GridWeb:
e.g
GridWeb1.WebWorksheets.Clear();–> used to explicitly clear all the sheets in the GridWeb control.

Thank you.