Spread for ASP.NET 8.0 Product Documentation
GetDataTable Method
Example 


Gets the data table associated with this model.
Syntax
'Declaration
 
Public Function GetDataTable() As DataTable
'Usage
 
Dim instance As DefaultSheetDataModel
Dim value As DataTable
 
value = instance.GetDataTable()
public DataTable GetDataTable()

Return Value

DataTable containing the data table
Example
This example attaches a DataTable to a DefaultSheetDataModel, which is then assigned to the DataModel of the spreadsheet. The DataRow, DataTable and DataView are returned to a list box.
private void Page_Load(object sender, System.EventArgs e)
  {
  if (this.IsPostBack) return;

  DataTable dt = new DataTable("FarPoint");
  dt.Columns.Add("Product");
  dt.Rows.Add(new Object[] {"Spread"});
  dt.Rows.Add(new Object[] {"Input Pro"});
  DataRow nrow;
  nrow = dt.NewRow();
  nrow["Product"] = "To Be Announced";
  dt.Rows.Add(nrow);
  dt.AcceptChanges();
  FarPoint.Web.Spread.Model.DefaultSheetDataModel dm = new FarPoint.Web.Spread.Model.DefaultSheetDataModel(dt);
  FpSpread1.ActiveSheetView.DataModel = dm;
  FpSpread1.ActiveSheetView.Columns[0].Width = 240;
  DataRowView drv;
  DataView dv;
  drv = dm.GetDataRow(1);
  dv = dm.GetDataView();
  ListBox1.Items.Add(Convert.ToString(drv.RowVersion));
  ListBox1.Items.Add(Convert.ToString(dm.GetDataTable()));
  ListBox1.Items.Add(Convert.ToString(dv.Count));
}
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

   If (Me.IsPostBack) Then Return

   Dim dt As New DataTable("FarPoint")
   dt.Columns.Add("Product")
   dt.Rows.Add(New Object() {"Spread"})
   dt.Rows.Add(New Object() {"Input Pro"})
   Dim nrow As DataRow
   nrow = dt.NewRow()
   nrow("Product") = "To Be Announced"
   dt.Rows.Add(nrow)
   dt.AcceptChanges()
   Dim dm As FarPoint.Web.Spread.Model.DefaultSheetDataModel = New FarPoint.Web.Spread.Model.DefaultSheetDataModel(dt)
   FpSpread1.ActiveSheetView.DataModel = dm
   FpSpread1.ActiveSheetView.Columns(0).Width = 240
   Dim drv As DataRowView
   Dim dv As DataView
   drv = dm.GetDataRow(1)
   dv = dm.GetDataView()
   ListBox1.Items.Add(drv.RowVersion.ToString())
   ListBox1.Items.Add(dm.GetDataTable.ToString)
   ListBox1.Items.Add(dv.Count.ToString)

 End Sub
Requirements

Target Platforms: Windows 7, Windows 8, Windows Vista, Windows Server 2000, Windows 2000 Professional, Windows XP Professional, Windows NT 4.0 Workstation, SP6, Windows NT 4.0 Server, SP6

See Also

Reference

DefaultSheetDataModel Class
DefaultSheetDataModel Members

 

 


Copyright © GrapeCity, inc. All rights reserved.