Binds the model column to a specified data source column.
Syntax
Parameters
- column
- Column index in the model
- value
- Data source column
Example
This example creates a DefaultSheetDataModel and assigns it to the DataModel of the spreadsheet. The data source of the model is attached to some DataTables and the SetModelDataColumn method rearranges which columns of the model are bound to which columns in the DataSet.
Visual Basic | Copy Code |
---|
PrivateSubPage_Load(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)HandlesMyBase.Load
If(IsPostBack)ThenReturn
DimdsAsNewSystem.Data.DataSet()
DimdmAsNewFarPoint.Web.Spread.Model.DefaultSheetDataModel()
FpSpread1.ActiveSheetView.DataModel=dm
DimempAsDataTable=NewDataTable("Employee")
DimlnameAsDataColumn=NewDataColumn("LastName",GetType(System.String))
DimfnameAsDataColumn=NewDataColumn("FirstName",GetType(System.String))
DimidAsDataColumn=emp.Columns.Add("ID",GetType(System.Int32))
id.AutoIncrement=True
DimprimarykeyAsDataColumn()=NewDataColumn(){id}
emp.PrimaryKey=primarykey
emp.Columns.Add(lname)
emp.Columns.Add(fname)
ds.Tables.Add(emp)
DimtiAsDataRow=emp.NewRow()
ti(lname)="Bazemoreland"
ti(fname)="Ti"
emp.Rows.Add(ti)
DimginnyAsDataRow=emp.NewRow()
ginny(lname)="Danielson"
ginny(fname)="Ginny"
emp.Rows.Add(ginny)
DimbobAsDataRow=emp.NewRow()
bob(lname)="Morrison"
bob(fname)="Bob"
emp.Rows.Add(bob)
ds.AcceptChanges()
dm.DataSource=ds
dm.SetModelDataColumn(0,"FirstName")
dm.SetModelDataColumn(2,0)
EndSub |
C# | Copy Code |
---|
privatevoidPage_Load(objectsender,System.EventArgse)
{
if(this.IsPostBack)return;
System.Data.DataSetds=newSystem.Data.DataSet();
FarPoint.Web.Spread.Model.DefaultSheetDataModeldm=newFarPoint.Web.Spread.Model.DefaultSheetDataModel();
FpSpread1.ActiveSheetView.DataModel=dm;
DataTableemp=newDataTable("Employee");
DataColumnlname=newDataColumn("LastName",typeof(String));
DataColumnfname=newDataColumn("FirstName",typeof(String));
DataColumnid=emp.Columns.Add("ID",typeof(Int32));
id.AutoIncrement=true;
emp.PrimaryKey=newDataColumn[]{id};
emp.Columns.Add(lname);
emp.Columns.Add(fname);
ds.Tables.Add(emp);
DataRowti=emp.NewRow();
ti[lname]="Bazemoreland";
ti[fname]="Ti";
emp.Rows.Add(ti);
DataRowginny=emp.NewRow();
ginny[lname]="Danielson";
ginny[fname]="Ginny";
emp.Rows.Add(ginny);
DataRowbob=emp.NewRow();
bob[lname]="Morrison";
bob[fname]="Bob";
emp.Rows.Add(bob);
ds.AcceptChanges();
dm.DataSource=ds;
dm.SetModelDataColumn(0,"FirstName");
dm.SetModelDataColumn(2,0);
} |
Requirements
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family
See Also