When you bind a worksheet to a dataset with the Worksheets Designer in the IDE, a worksheet tag will be created in the aspx file, and it may look like this:
<agw:Worksheet DataMember="Products" BindStartRow="2" Name="Products" EnableCreateBindColumnHeader="True" DataSource='<%# dataSet11 %>'>
When you call the GridWeb1.DataBind() or the WebWorksheet.DataBind(), the worksheet will be filled with the data in the dataSet11.
Sometimes you may want to rebind the worksheet. You may write like this:
[C#]
private void Button1_Click(object sender, System.EventArgs e)
{
GridWeb1.WebWorksheets[0].Cells.Clear();
// Load data to the dataSet11.
LoadData(dataSet11);
GridWeb1.WebWorksheets[0].DataBind();
}
[VB]
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
GridWeb1.WebWorksheets(0).Cells.Clear()
' Load data to the dataSet11.
LoadData(dataSet11)
GridWeb1.WebWorksheets(0).DataBind()
End Sub
You may notice that the worksheet will always bind to the dataSet11 even if you change the worksheet.DataSource property at runtime. This is because that the sheet will alway use the DataSource binding information in the worksheet's tag in the aspx file. So if you want to bind the sheet to another datasource at runtime, you should remove the datasource binding information in the worksheet tag in the aspx file. Just edit the tag to this:
<agw:Worksheet BindStartRow="2" Name="Products" EnableCreateBindColumnHeader="True">
And you should specify the worksheet.DataSource and worksheet.DataMember properties before each time you want to call the DataBind method.