Spread for ASP.NET 11 Product Documentation
GetKey Method (DefaultSheetDataModel)
Example 


FarPoint.Web.Spread Assembly > FarPoint.Web.Spread.Model Namespace > DefaultSheetDataModel Class : GetKey Method
If UseRowIndex is true, this is the row index; otherwise, this is the column index
Gets a key for the specified row or column.
Syntax
'Declaration
 
Public Function GetKey( _
   ByVal index As Integer _
) As Object
'Usage
 
Dim instance As DefaultSheetDataModel
Dim index As Integer
Dim value As Object
 
value = instance.GetKey(index)
public object GetKey( 
   int index
)

Parameters

index
If UseRowIndex is true, this is the row index; otherwise, this is the column index

Return Value

Object associated with this row or column as its key
Remarks

If the UseRowIndex property is set to true, the method generates a key for the specified row. Otherwise, the GetKey method generates a key for the specified column.

Example
This example calls the GetKey method to return the key for the first row.
Dim ds As New System.Data.DataSet()

Private Sub Page_Load(ByVal sender As System.Object,ByVal e As System.EventArgs)Handles MyBase.Load

If(Me.IsPostBack)Then Return

CreateDataSet()
FpSpread1.Sheets(0).DataSource=ds
FpSpread1.Sheets(0).DataMember="names"
FpSpread1.Sheets(0).DataKeyField="first"

Dim dm As FarPoint.Web.Spread.Model.DefaultSheetDataModel=CType(FpSpread1.ActiveSheetView.DataModel,FarPoint.Web.Spread.Model.DefaultSheetDataModel)
ListBox1.Items.Add(dm.GetKey(0))
End Sub

Private Sub CreateDataSet()
Dim names As DataTable
names=ds.Tables.Add("names")
names.Columns.Add("first")
names.Columns.Add("last")
names.Columns.Add("index")
names.Rows.Add(New Object(){"bob","morris",0})
names.Rows.Add(New Object(){"sean","morris",1})
names.Rows.Add(New Object(){"chris","morris",2})
End Sub
System.Data.DataSet ds=new System.Data.DataSet();

private void Page_Load(object sender,System.EventArgs e)
{
if(this.IsPostBack)return;

CreateDataSet();
FpSpread1.Sheets[0].DataSource=ds;
FpSpread1.Sheets[0].DataMember="names";
FpSpread1.Sheets[0].DataKeyField="first";

FarPoint.Web.Spread.Model.DefaultSheetDataModel dm=(FarPoint.Web.Spread.Model.DefaultSheetDataModel)FpSpread1.ActiveSheetView.DataModel;
ListBox1.Items.Add(dm.GetKey(0).ToString());
}

private void CreateDataSet()
{
DataTable names;
names=ds.Tables.Add("names");
names.Columns.Add("first");
names.Columns.Add("last");
names.Columns.Add("index");
names.Rows.Add(new object[]{"bob","morris",0});
names.Rows.Add(new object[]{"sean","morris",1});
names.Rows.Add(new object[]{"chris","morris",2});
}
See Also

Reference

DefaultSheetDataModel Class
DefaultSheetDataModel Members
UseRowIndex Property