PowerTools SPREAD for ASP.NET 8.0J
DataSource プロパティ (DefaultSheetDataModel)

データソースを取得または設定します。
構文
'Declaration
 
Public Property DataSource As Object
public object DataSource {get; set;}

プロパティ値

データソースの名前を含むString
例外
例外説明
System.ArgumentExceptionデータソースが空です。
この例では、DefaultSheetDataModeを作成し、それをスプレッドシートのDataModelに割り当てます。モデルのデータソースを一部のDataTablesに付加し、ParentRelationNameとParentRowIndexをリストボックスに返します。
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
	If IsPostBack Then Return

	Dim ds As New System.Data.DataSet()
	Dim dm As New FarPoint.Web.Spread.Model.DefaultSheetDataModel()
	FpSpread1.ActiveSheetView.DataModel = dm
	FpSpread1.HierarchicalView = True

	Dim emp As DataTable = New DataTable("Employee")
	Dim dept As DataTable = New DataTable("Department")

	Dim lname As DataColumn = New DataColumn("LastName", GetType(System.String))
	Dim fname As DataColumn = New DataColumn("FirstName", GetType(System.String))

	Dim dname As DataColumn = New DataColumn("DeptName", GetType(System.String))
	Dim area As DataColumn = New DataColumn("Area", GetType(System.String))

	Dim id As DataColumn = emp.Columns.Add("ID", GetType(System.Int32))
	id.AutoIncrement = True
	Dim primarykey As DataColumn() = New DataColumn(){ id }
	emp.PrimaryKey = primarykey
	emp.Columns.Add(lname)
	emp.Columns.Add(fname)

	id = dept.Columns.Add("ID", GetType(System.Int32))
	id.AutoIncrement = True
	dept.PrimaryKey = New DataColumn(){ id }
	id.AutoIncrement = True
	Dim lang As DataColumn = dept.Columns.Add("Language", GetType(System.Int32))
	Dim foreignkey As DataColumn() = New DataColumn(){ lang }
	dept.Columns.Add(dname)
	dept.Columns.Add(area)

	ds.Tables.Add(emp)
	ds.Tables.Add(dept)

	Dim ti As DataRow = emp.NewRow()
	ti(lname) = "Bazemoreland"
	ti(fname) = "Ti"
	emp.Rows.Add(ti)

	Dim ginny As DataRow = emp.NewRow()
	ginny(lname) = "Danielson"
	ginny(fname) = "Ginny"
	emp.Rows.Add(ginny)

	Dim bob As DataRow = emp.NewRow()
	bob(lname) = "Morrison"
	bob(fname) = "Bob"
	emp.Rows.Add(bob)

	Dim rel As DataRelation = New DataRelation("GrapeCity", primarykey, foreignkey, False)
	ds.Relations.Add(rel)

	Dim row As DataRow = dept.NewRow()
	row("Language") = ti("ID")
	row(dname) = "TechSupport"
	row(area) = "C#"
	dept.Rows.Add(row)

	row = dept.NewRow()
	row("Language") = ginny("ID")
	row(dname) = "TechSupport"
	row(area) = "VB.Net"
	dept.Rows.Add(row)
	row = dept.NewRow()
	row("Language") = bob("ID")
	row(dname) = "TechSupport"
	row(area) = "C#"
	dept.Rows.Add(row)
	ds.AcceptChanges()
	dm.DataSource = ds
	dm.DataMember = "Employee"

	Dim dm2 As FarPoint.Web.Spread.Model.DefaultSheetDataModel
	dm2 = FpSpread1.Sheets(0).GetChildView(0, 0).DataModel
	ListBox1.Items.Add(dm2.ParentRelationName)
	ListBox1.Items.Add(dm2.ParentRowIndex)
	ListBox1.Items.Add(dm.ChildRelationCount)
End Sub
private void Page_Load(object sender, System.EventArgs e)
{
	System.Data.DataSet ds = new System.Data.DataSet();
	FarPoint.Web.Spread.Model.DefaultSheetDataModel dm;
	dm = new FarPoint.Web.Spread.Model.DefaultSheetDataModel();
	FpSpread1.ActiveSheetView.DataModel = dm;
	FpSpread1.HierarchicalView = true;
	DataTable emp = new DataTable ("Employee");
	DataTable dept = new DataTable ("Department");

	DataColumn lname = new DataColumn ("LastName", typeof(String));
	DataColumn fname = new DataColumn ("FirstName", typeof(String));

	DataColumn dname = new DataColumn ("DeptName", typeof(String));
	DataColumn area = new DataColumn ("Area", typeof(String));

	DataColumn id = emp.Columns.Add("ID", typeof(Int32));
	id.AutoIncrement = true;
	emp.PrimaryKey = new DataColumn[] { id };
	emp.Columns.Add(lname);
	emp.Columns.Add(fname);

	id = dept.Columns.Add("ID", typeof(Int32));
	id.AutoIncrement = true;
	dept.PrimaryKey = new DataColumn[] { id };
	id.AutoIncrement = true;
	DataColumn lang = dept.Columns.Add("Language", typeof(Int32));
	DataColumn[] foreignkey = new DataColumn[] { lang };
	dept.Columns.Add(dname);
	dept.Columns.Add(area);

	ds.Tables.Add(emp);
	ds.Tables.Add(dept);

	DataRow ti = emp.NewRow();
	ti[lname] = "Bazemoreland";
	ti[fname] = "Ti";
	emp.Rows.Add(ti);

	DataRow ginny = emp.NewRow();
	ginny[lname] = "Danielson";
	ginny[fname] = "Ginny";
	emp.Rows.Add(ginny);

	DataRow bob = emp.NewRow();
	bob[lname] = "Morrison";
	bob[fname] = "Bob";
	emp.Rows.Add(bob);

	DataRelation rel = new DataRelation("GrapeCity", emp.PrimaryKey, foreignkey, false);
	ds.Relations.Add(rel);

	DataRow row = dept.NewRow();
	row["Language"] = ti["ID"];
	row[dname] = "TechSupport";
	row[area] = "C#";
	dept.Rows.Add(row);

	row = dept.NewRow();
	row["Language"] = ginny["ID"];
	row[dname] = "TechSupport";
	row[area] = "VB.Net";
	dept.Rows.Add(row);
	row = dept.NewRow();
	row["Language"] = bob["ID"];
	row[dname] = "TechSupport";
	row[area] = "C#";
	dept.Rows.Add(row);
	ds.AcceptChanges();
	dm.DataSource = ds;
	dm.DataMember = "Employee";
	FarPoint.Web.Spread.Model.DefaultSheetDataModel dm2;
	dm2 = (FarPoint.Web.Spread.Model.DefaultSheetDataModel)FpSpread1.Sheets[0].GetChildView(0, 0).DataModel;
	ListBox1.Items.Add(dm2.ParentRelationName);
	ListBox1.Items.Add(Convert.ToString(dm2.ParentRowIndex));
	ListBox1.Items.Add(Convert.ToString(dm.ChildRelationCount));
}
参照

DefaultSheetDataModel クラス
DefaultSheetDataModel メンバ

 

 


© 2003-2015, GrapeCity inc. All rights reserved.