Spread for ASP.NET 8.0 Product Documentation
GetView Method
Example 


String with the name of the view
Gets the named data source view associated with the data source control.
Syntax
'Declaration
 
Public Function GetView( _
   ByVal viewName As String _
) As DataSourceView
'Usage
 
Dim instance As SpreadDataSource
Dim viewName As String
Dim value As DataSourceView
 
value = instance.GetView(viewName)
public DataSourceView GetView( 
   string viewName
)

Parameters

viewName
String with the name of the view

Return Value

SpreadDataSourceView object
Example

This example binds a cell range and uses many methods of the SpreadDataSource and SpreadDataSourceView classes.

FpSpread1.Sheets[0].ColumnHeader.Cells[0, 0].Value = "UserName";
FpSpread1.Sheets[0].Cells[0, 0].Value = "Test";
FpSpread1.Sheets[0].Cells[1, 0].Value = "Ann";
FpSpread1.Sheets[0].Cells[2, 0].Value = "Doug";
FarPoint.Web.Spread.SpreadDataSource spreadDS = new FarPoint.Web.Spread.SpreadDataSource();
spreadDS.SheetName = FpSpread1.ActiveSheetView.SheetName;
spreadDS.SpreadID = "FpSpread1";//FpSpread1.ID;
spreadDS.CellRange = new FarPoint.Web.Spread.Model.CellRange(0, 0, 3, 1);

//Add the Spread data source to the page
this.Controls.Add(spreadDS);

// GetData() method
System.Collections.IEnumerable enmrable;
System.Collections.IEnumerator enmr;
enmrable = spreadDS.GetData();                       
enmr = enmrable.GetEnumerator();
ListBox1.DataTextField = "UserName";
while (enmr.MoveNext()) 
   { 
    ListBox1.Items.Add(Convert.ToString(enmr.Current)); 
    }
       
// GetViewNames() method
System.Collections.ICollection c;
c = spreadDS.GetViewNames();        
string[] arr= new string[2];
c.CopyTo(arr, 0);
ListBox1.Items.Add(c.Count.ToString());
if (arr[0] == "") 
   {
    ListBox1.Items.Add("return correct value");
   }
       
// GetView() method
System.Web.UI.DataSourceView DSView;              
DSView = spreadDS.GetView(arr[0]);        
ListBox1.Items.Add(DSView.CanDelete.ToString());
ListBox1.Items.Add(DSView.CanInsert.ToString());
ListBox1.Items.Add(DSView.CanUpdate.ToString());
ListBox1.Items.Add(DSView.CanSort.ToString());
FpSpread1.Sheets(0).ColumnHeader.Cells(0, 0).value = "UserName"
FpSpread1.Sheets(0).Cells(0, 0).Value = "Test"
FpSpread1.Sheets(0).Cells(1, 0).Value = "Ann"
FpSpread1.Sheets(0).Cells(2, 0).Value = "Doug"

Dim spreadDS As New FarPoint.Web.Spread.SpreadDataSource()
spreadDS.SheetName = FpSpread1.ActiveSheetView.SheetName
spreadDS.SpreadID = "FpSpread1"
spreadDS.CellRange = New FarPoint.Web.Spread.Model.CellRange(0, 0, 3, 1)

'Add the Spread Data Source to the page
Controls.Add(spreadDS)

Dim spreadDSV = New FarPoint.Web.Spread.SpreadDataSourceView(spreadDS)
ListBox1.Items.Add(spreadDSV.CanDelete.ToString())
ListBox1.Items.Add(spreadDSV.CanInsert.ToString())
ListBox1.Items.Add(spreadDSV.CanUpdate.ToString())
ListBox1.Items.Add(spreadDSV.CanSort.ToString())

' for GetData() method
Dim enmrable As System.Collections.IEnumerable
Dim enmr As System.Collections.IEnumerator
enmrable = spreadDS.GetData()
enmr = enmrable.GetEnumerator()
ListBox1.DataTextField = "UserName"
While enmr.MoveNext()
   ListBox1.Items.Add(Convert.ToString(enmr.Current))
End While

' for GetViewNames() method
Dim c As System.Collections.ICollection
c = spreadDS.GetViewNames()
 Dim arr(2) As String
c.CopyTo(arr, 0)
ListBox1.Items.Add(c.Count.ToString())
If arr(0) = "" Then
   ListBox1.Items.Add("return correct value")
End If

' for GetView() method
Dim DSView As System.Web.UI.DataSourceView
DSView = spreadDS.GetView(arr(0))
ListBox1.Items.Add(DSView.CanDelete.ToString())
ListBox1.Items.Add(DSView.CanInsert.ToString())
ListBox1.Items.Add(DSView.CanUpdate.ToString())
ListBox1.Items.Add(DSView.CanSort.ToString())
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

SpreadDataSource Class
SpreadDataSource Members

 

 


Copyright © GrapeCity, inc. All rights reserved.