本文整理汇总了C#中System.Web.UI.WebControls.WebParts.ConnectionProviderAttribute类的典型用法代码示例。如果您正苦于以下问题:C# ConnectionProviderAttribute类的具体用法?C# ConnectionProviderAttribute怎么用?C# ConnectionProviderAttribute使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionProviderAttribute类属于System.Web.UI.WebControls.WebParts命名空间,在下文中一共展示了ConnectionProviderAttribute类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetConnectionInterface
[ConnectionProvider("Row")]
public IWebPartRow GetConnectionInterface()
{
return new RowProviderWebPart();
}
示例2: RowProviderWebPart
//引入命名空间
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Reflection;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
//This sample code creates a Web Parts control that acts as a provider of row data.
namespace My
{
public sealed class RowProviderWebPart : WebPart, IWebPartRow
{
private DataTable _table;
public RowProviderWebPart()
{
_table = new DataTable();
DataColumn col = new DataColumn();
col.DataType = typeof(string);
col.ColumnName = "Name";
_table.Columns.Add(col);
col = new DataColumn();
col.DataType = typeof(string);
col.ColumnName = "Address";
_table.Columns.Add(col);
col = new DataColumn();
col.DataType = typeof(int);
col.ColumnName = "ZIP Code";
_table.Columns.Add(col);
DataRow row = _table.NewRow();
row["Name"] = "John Q. Public";
row["Address"] = "123 Main Street";
row["ZIP Code"] = 98000;
_table.Rows.Add(row);
}
[ConnectionProvider("Row")]
public IWebPartRow GetConnectionInterface()
{
return new RowProviderWebPart();
}
public PropertyDescriptorCollection Schema
{
get {
return TypeDescriptor.GetProperties(_table.DefaultView[0]);
}
}
public void GetRowData(RowCallback callback)
{
callback(_table.Rows);
}
}
}
示例3: GetRowData
//引入命名空间
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Reflection;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
// This sample code creates a Web Parts control that acts as a consumer of row data.
namespace My
{
public sealed class RowConsumerWebPart : WebPart {
private IWebPartRow _provider;
private ICollection _tableData;
private void GetRowData(object rowData)
{
_tableData = (ICollection)rowData;
}
protected override void OnPreRender(EventArgs e)
{
if (_provider != null)
{
_provider.GetRowData(new RowCallback(GetRowData));
}
}
protected override void RenderContents(HtmlTextWriter writer) {
if (_provider != null) {
PropertyDescriptorCollection props = _provider.Schema;
int count = 0;
if (props != null && props.Count > 0 && _tableData != null) {
foreach (PropertyDescriptor prop in props)
{
foreach (DataRow o in _tableData)
{
writer.Write(prop.DisplayName + ": " + o[count]);
writer.WriteBreak();
writer.WriteLine();
count = count + 1;
}
}
}
else {
writer.Write("No data");
}
}
else {
writer.Write("Not connected");
}
}
[ConnectionConsumer("Row")]
public void SetConnectionInterface(IWebPartRow provider)
{
_provider = provider;
}
}
}
//}