Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
Description

Excerpt

Sets a row's data source to an

Msdn
System.Collections.IDictionary
System.Collections.IDictionary
1IDictionary
. An IDictionary represents a collection of key-and-value pairs.  

When binding an IDictionary horizontally, you must insert a datamarker for each value you want displayed.

Signature
C#
C#
public virtual void BindRowData(System.Collections.IDictionary dataSource, System.String dataSourceName, DataBindingProperties property)
Signature
vb.net
vb.net
Public Overridable Sub BindRowData(ByVal dataSource As System.Collections.IDictionary, ByVal dataSourceName As String, ByVal [property] As DataBindingProperties)
Parameters
Param
dataSource
dataSource

An IDictionary collection of key-and-value pairs to use as the data source.

Param
dataSourceName
dataSourceName

The name of the data marker at which to insert the values imported from the data source. For example, to bind a data source to the data marker %%=Orders.OrderId, the value of dataSourceName should be "Orders". The string passed must begin with a letter.

Param
property
property

The DataBindingProperties object which contains information about how the data should be bound to the template. property Must be specified, but the DataBindingProperties need not be set beforehand. To bind data to a template with the default DataBindingProperties, pass in ExcelTemplate.CreateDataBindingProperties() as the property value. Otherwise, use the ExcelTemplate.CreateDataBindingProperties() method to generate a new DataBindingProperties object and set the DataBindingProperties.MaxRows, DataBindingProperties.Transpose, and/or DataBindingProperties.WorksheetName properties for the workbook.

Exceptions
Exception
ArgumentNullException
ArgumentNullException

BindRowData will throw this exception if null (C#) or Nothing (VB.NET) is passed to the method.

Exception
ArgumentException
ArgumentException

Remarks

You can set several data sources for a single template. Use the following methods to set template data sources: BindCellData, BindColumnData,BindRowData, and BindData.

Example
Code Block
csharp
csharp
titleC#

          ExcelTemplate xlt = new ExcelTemplate();
          xlt.Open(@"C:\ExcelWriter\EmployeeOrdersTemplate.xls");

          //--- Bind the IDictionary collection to the
          //--- %%=Orders.[Field] data marker.
          xlt.BindRowData(OrdersColl,
               "Orders",
               xlt.CreateDataBindingProperties());
          xlt.Process();
          xlt.Save(Page.Response, "EmployeeOrders.xls", false);
        
Code Block
vb.net
vb.net
titlevb.net

          Dim xlt As New ExcelTemplate()
          xlt.Open("C:\ExcelWriter\EmployeeOrdersTemplate.xls")

          '--- Bind the IDictionary collection to the
          '--- %%=Orders.[Field] data marker.
          xlt.BindRowData(OrdersColl, _
               "Orders", _
               xlt.CreateDataBindingProperties())
          xlt.Process()
          xlt.Save(Page.Response, "EmployeeOrders.xls", False)