Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
IRepeatInfoUser.RenderItem Method

CheckBoxList.IRepeatInfoUser.RenderItem Method

This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.

For a description of this member, see RenderItem.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

void IRepeatInfoUser.RenderItem(
	ListItemType itemType,
	int repeatIndex,
	RepeatInfo repeatInfo,
	HtmlTextWriter writer
)

Parameters

itemType
Type: System.Web.UI.WebControls.ListItemType
One of the ListItemType enumeration values.
repeatIndex
Type: System.Int32
An ordinal index that specifies the location of the item in the list control.
repeatInfo
Type: System.Web.UI.WebControls.RepeatInfo
A RepeatInfo object that represents the information used to render the item in the list.
writer
Type: System.Web.UI.HtmlTextWriter
An System.Web.UI.HtmlTextWriter object that represents the output stream to render HTML content on the client.

Implements

IRepeatInfoUser.RenderItem(ListItemType, Int32, RepeatInfo, HtmlTextWriter)

Typically, you should use the CheckBoxList.RenderItem method to render items in a CheckBoxList object.

The IRepeatInfoUser.RenderItem method is an explicit interface member implementation. It can be used only when the CheckBoxList instance is cast to an IRepeatInfoUser interface.

Notes to Implementers

To define a custom implementation for rendering items in a CheckBoxList object, override the CheckBoxList.RenderItem member. The explicit interface implementation calls the CheckBoxList.RenderItem method to render an item in the control.

The following code example demonstrates how to use the IRepeatInfoUser interface members on a custom CheckBoxList object.


<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page language="c#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head>
    <title>Custom CheckBoxList - IRepeatInfoUser - C# Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom CheckBoxList - IRepeatInfoUser - C# Example</h3>
      <aspSample:CustomCheckBoxListIRepeatInfoUser
        id="CheckBoxList1" runat="server">
          <asp:ListItem Selected="True">Item 1</asp:ListItem>
          <asp:ListItem>Item 2</asp:ListItem>
          <asp:ListItem>Item 3</asp:ListItem>
          <asp:ListItem>Item 4</asp:ListItem>
          <asp:ListItem>Item 5</asp:ListItem>
          <asp:ListItem>Item 6</asp:ListItem>
      </aspSample:CustomCheckBoxListIRepeatInfoUser>
    </form>
  </body>
</html>


...


using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
    [AspNetHostingPermission(SecurityAction.Demand, Level = 
        AspNetHostingPermissionLevel.Minimal)]
    public class CustomCheckBoxListIRepeatInfoUser : CheckBoxList
    {
        private bool hasFooter;
        private bool hasHeader;
        private bool hasSeparators;
        private int repeatedItemCount;
        private Style itemStyleItem;

        protected override void OnPreRender(System.EventArgs e)
        {
            // Call the base class's OnPreRender method
            base.OnPreRender(e);

            // Get a self-referencing IRepeatInfoUser object
            IRepeatInfoUser repeatInfoUser = (IRepeatInfoUser)this;

            // Get the IRepeatInfoUser members values.
            hasFooter = repeatInfoUser.HasFooter;
            hasHeader = repeatInfoUser.HasHeader;
            hasSeparators = repeatInfoUser.HasSeparators;
            repeatedItemCount = repeatInfoUser.RepeatedItemCount;
            itemStyleItem = repeatInfoUser.GetItemStyle(ListItemType.Item, 0);
        }

        protected override void Render(HtmlTextWriter writer)
        {
            // Create and setup a RepeatInfo class.
            RepeatInfo repeatInfo = new RepeatInfo();
            repeatInfo.RepeatColumns = 0;
            repeatInfo.RepeatDirection = RepeatDirection.Horizontal;
            repeatInfo.RepeatLayout = RepeatLayout.Table;

            // Get a self-referencing IRepeatInfoUser object
            IRepeatInfoUser repeatInfoUser = (IRepeatInfoUser)this;

            // Render the items using the above RepeatInfo class.
            repeatInfoUser.RenderItem(ListItemType.Item, 0, repeatInfo, writer);
            repeatInfoUser.RenderItem(ListItemType.Item, 1, repeatInfo, writer);
            repeatInfoUser.RenderItem(ListItemType.Item, 2, repeatInfo, writer);
            repeatInfoUser.RenderItem(ListItemType.Item, 3, repeatInfo, writer);
            repeatInfoUser.RenderItem(ListItemType.Item, 4, repeatInfo, writer);
            repeatInfoUser.RenderItem(ListItemType.Item, 5, repeatInfo, writer);
        }
    }
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2015 Microsoft