当前位置: 首页>>代码示例>>C#>>正文


C# Repeater.GetType方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.Repeater.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Repeater.GetType方法的具体用法?C# Repeater.GetType怎么用?C# Repeater.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.Repeater的用法示例。


在下文中一共展示了Repeater.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FieldValueAtIndex

//  FieldValueAtIndex
//
//  PURPOSE:  This function determines the value of a named field within some row within
//		this DataSet.  The tricky part is determining which row is desired.  Consider an
//		example.  Suppose we have a page containing 3 DataSets:  ds1, ds2 and ds3.  This
//		page might contain a DataGrid, g1, bound to ds1.  Within the DataGrid may be
//		with a TemplateColumn containing a Repeater, r1, bound to ds2.  Within the Repeater
//		might be an ItemTemplate containing ds1.FieldValue("foo", Container) as well as
//		ds2.FieldValue("bar", Container).  Outside the whole DataGrid might be another
//		Repeater, r2, bound to ds1 containing an ItemTemplate containing
//		ds1.FieldValue("foo", Container) and ds3.FieldValue("xyz", Container).  We can
//		diagram this as:
//
//		DataSet ds1
//		DataSet ds2
//		DataSet ds3
//
//		DataGrid g1 bound to ds1
//			TemplateColumn
//				ItemTemplate
//					Repeater r1 bound to ds2
//						ItemTemplate
//							ds1.FieldValue("foo", Container)  [use the row in ds1 that g1 is currently processing]
//							ds2.FieldValue("bar", Container)  [use the row in ds2 that r1 is currrently processing]
//
//		Repeater r2 bound to ds1
//			ds1.FieldValue("foo", Container) [use the row in ds1 that r2 is currently processing]
//			ds3.FieldValue("xyz", Container) [use the 0th row in ds3]
//		
//		The challenge presented to this method is to resolve the field values according to the
//		description shown above in square brackets.
//
public string FieldValueAtIndex(int Index, string FieldName, System.Web.UI.Control Container)
{
	string strReturn = "";  // contains the field value that we eventually resolve to

	try
	{
		//  Make some objects so we can get their types to use later in comparisons.

		System.Web.UI.WebControls.Repeater theRepeater = new System.Web.UI.WebControls.Repeater();
		System.Web.UI.WebControls.DataList theDataList = new System.Web.UI.WebControls.DataList();
		System.Web.UI.WebControls.DataGrid theDataGrid = new System.Web.UI.WebControls.DataGrid();

		System.Web.UI.WebControls.RepeaterItem repeaterItemContainer = new System.Web.UI.WebControls.RepeaterItem(0, ListItemType.Item);
		System.Web.UI.WebControls.DataListItem dataListItemContainer = new System.Web.UI.WebControls.DataListItem(0, ListItemType.Item);
		System.Web.UI.WebControls.DataGridItem dataGridItemContainer = new System.Web.UI.WebControls.DataGridItem(0, 0, ListItemType.Item);

		Type repeaterType = theRepeater.GetType();
		Type dataListType = theDataList.GetType();
		Type dataGridType = theDataGrid.GetType();
		 
		Type repeaterItemType = repeaterItemContainer.GetType();
		Type dataListItemType = dataListItemContainer.GetType();
		Type dataGridItemType = dataGridItemContainer.GetType();

		theRepeater = null;
		theDataList = null;
		theDataGrid = null;

		//  We will now figure out what control (Repeater, DataList or DataGrid) this DataSet
		//  has been bound to.  Later we can figure out what row that control is presently
		//  processing.

		Control theParent = null;

		if (Container != null)
		{
			theParent = Container.Parent;
			while (theParent != null)
			{
				if (repeaterType.IsInstanceOfType(theParent))
				{
					theRepeater = (System.Web.UI.WebControls.Repeater)theParent;
					if (theRepeater.DataSource == this.DefaultView)
					{
						break;
					}
				}
				else if (dataListType.IsInstanceOfType(theParent))
				{
					theDataList = (System.Web.UI.WebControls.DataList)theParent;
					if (theDataList.DataSource == this.DefaultView)
					{
						break;
					}
				}
				else if (dataGridType.IsInstanceOfType(theParent))
				{
					theDataGrid = (System.Web.UI.WebControls.DataGrid)theParent;
					if (theDataGrid.DataSource == this.DefaultView)
					{
						break;
					}
				}

				theParent = theParent.Parent;
			}

			//  Finding the control that this DataSet is bound to isn't enough.  
//.........这里部分代码省略.........
开发者ID:lyw199507142525,项目名称:lyw199507142525.github.io,代码行数:101,代码来源:DreamweaverCtrls.cs


注:本文中的System.Web.UI.WebControls.Repeater.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。