.NET Questions and Solutions

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘microsoft knowledge base article’

An application that uses the ADO interface may malfunction, or data loss may occur when the application connects to SQL Server in Windows Vista, in Windows XP, or in Windows Server 2008

Symptoms
Consider the following scenario:An application connects to one of the following products: Microsoft SQL Server 2005 Microsoft SQL Server 2005 Express EditionMicrosoft SQL Server 2000SQL Server Desktop Engine (also known as MSDE 2000)The application uses the SET NOCOUNT ON statement for the connection. The application uses a Microsoft ActiveX Data Objects (ADO) client-side cursor toinsert a row into a table that has an identity column. When the application queries the identity column value of the newly inserted row, the value “0″ is returned incorrectly. When this value is returned, an application that uses the ActiveX Data Objects (ADO) interfacemay malfunction, or data loss may occur. Whether a malfunction or data loss occurs depends on how the application handles this scenario.
Note This problemoccurs only if the application uses a client-side cursor. If the application uses a server-side cursor, the application is not affected.
This problem occurs in the Microsoft Data Access Components (MDAC) components of the following Windows operating systems: Windows Vista Service Pack 1 (SP1)Windows XP Service Pack 2 (SP2) with hotfix 940569 Windows XP Service Pack 3 (SP3) Windows Server 2008
Resolution
To resolve this issue, install the hotfix that is described in the following Microsoft Knowledge Base article:
961451?(http://support.microsoft.com/kb/961451/) FIX: You receive an incorrect value when you query the last-inserted identity value after you use a client-side cursor to insert data to a table that contains an identity column in an application that uses ActiveX Data ObjectsNote The hotfix that was described in the “Resolution” section in the earlier version of this article is superseded by the hotfix that is described in 961451.

FIX: A NACK message from a Web service does not contain the details of the original exception in BizTalk Server 2006

Symptoms
Consider the following scenario. An orchestration is published as a Web service. The Web service redirects the SOAP request to an external Web service. The external Web service returns a SOAP exception. In this scenario, the negative acknowledgement (NACK) message in Microsoft BizTalk Server 2006 does not contain the details of the original exception. If the hotfix in Microsoft Knowledge Base article 927492 has been installed, the NACK message may be correct. However, the message format may be incorrect. This may cause a NullReferenceException error message.
Resolution
Hotfix information A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.
If the hotfix is available for download, there is a “Hotfix download available” section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.
Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or tocreate a separate service request, visit the following Microsoft Web site:
http://support.microsoft.com/contactus/?ws=support(http://support.microsoft.com/contactus/?ws=support)Note The “Hotfix download available” form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.PrerequisitesYou must have BizTalk Server 2006 installed to apply this hotfix.Restart requirementYou do not have to restart the computer after you apply this hotfix.Hotfix replacement informationThis hotfix does not replace a previously released hotfix.File information The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.
Collapse this tableExpand this table
File nameFile versionFile sizeDateTimePlatformMicrosoft.biztalk.webservices.serverproxy.dll3.5.1714.054,34428-Sep-200717:42×86Note Because of file dependencies, the most recent hotfix that contains these files may also contain additional files.

Fatal Exception 0028 in VXD Helpwgrd

Symptoms
When you start Windows 98, you may receive the following error message:

Fatal Exception 0028 in VXD HELPWGRDNOTE: To more effectively search the Microsoft Knowledge Base, use keywords that relate to your issue. If you are searching for troubleshooting information that is not mentioned in this article, search the Microsoft Knowledge Base again by using keywords that are listed in the following Microsoft Knowledge Base article:
242450?(http://support.microsoft.com/kb/242450/EN-US/) How to Query the Microsoft Knowledge Base Using Keywords
Resolution
This behavior can occur if the Dr. Solomon’s Anti-Virus program is installed on your computer. The Dr. Solomon’s Anti-Virus program is not compatible with Windows 98.

Description of the PerformancePoint Server 2007 hotfix package: April 28, 2009

Symptoms
This article describes the Microsoft Office PerformancePoint Server 2007 issues that are fixed in the hotfix package that is dated April 28, 2009.
This article describes the following items about the hotfix package:The issues that the hotfix package fixes.The prerequisites for installing the hotfix package.Whether you must restart the computer after you install the hotfix package.Whether the hotfix package is replaced by any other hotfix package.Whether you must make any registry changes.The files that the hotfix package contains.
Resolution
PerformancePoint Server 2007 hotfixes are created for the release version of PerformancePoint Server 2007. All PerformancePoint Server 2007 hotfix packages are cumulative.
A hotfix package is available for PerformancePoint Server 2007. The build of this hotfix package is 3.0.4315.00. The release version of PerformancePoint Server 2007 must be installed before you apply this hotfix. The build of the release version of PerformancePoint Server 2007 is 3.0.3520.0.
Issue that the hotfix package fixesThis hotfix package fixes the following PerformancePoint Server 2007 Monitoring and Analytics issues that were not previously documented in a Microsoft Knowledge Base article.Issue 1: You cannot browse the list of Web parts when you are editing a dashboard that is deployed to a SharePoint siteIn PerformancePoint Dashboard Designer, you edit a dashboard that is deployed to a SharePoint site. When you try to browse the list of Web parts by clicking Next on the Add Web Parts panel, you receive the following error message:

Server Error in ‘/’ Application.
Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Important After you apply this hotfix, you must redeploy the Dashboard Viewer for SharePoint Services Web part. To redeploy this Web part, follow these steps:Start the Monitoring Server Configuration Manager.Remove the Dashboard Viewer for SharePoint Services Web part.Re-add the Dashboard Viewer for SharePoint Services Web part.Issue 2: Time Intelligence Post Formula filters display the next day’s dateYou link a Time Intelligence Post Formula filter to a scorecard in PerformancePoint Dashboard Designer. When you preview this dashboard, you notice that the Time Intelligence Post Formula filter displays a date that isone day in advance on the scorecard. For example, the date on the client computer is March 6. When you preview this dashboard, you expect the Time Intelligence Post Formula filter to display the date asMarch 6. However, the Time Intelligence Post Formula filter displays that date as March 7. This problem occurs when a a time zone difference causes a one-day differencebetween the client computer and the server.
This problem occurs because the date on the server is not converted from Coordinated Universal Time (Greenwich Mean Time) to local time.Issue 3: Member property values may not be displayed correctly in reports or in chartsWhen a member property value is displayed in reports or in charts, you may encounter one of the following problems:The precision may be lost if the value has more than two decimal places. For example, a value of 0.001 is displayed as 0.00.The value “,00″ is added to the end of the value. For example, a value of 88.00 is displayed as 88.880,00.Issue 4: The connection to SQL Server 2008 Reporting Services fails in PerformancePoint Dashboard DesignerWhen you try to connect to a SQL Server 2008 Reporting Services report in PerformancePoint Dashboard Designer, you receive an “Unable to connect to server” error message.

Description of the Outlook 2007 hotfix package: June 12, 2007

Symptoms
This article describes the Microsoft Office Outlook 2007 issues that are fixed in the Outlook 2007 hotfix package that is dated June 12, 2007.
This article describes the following items about the hotfix package:The issues that the hotfix package fixes.The prerequisites for installing the hotfix package.Whether you must restart your computer after you install the hotfix package.Whether the hotfix package is replaced by any other hotfix package.Whether you must make any registry changes. The files that the hotfix package contains.
Resolution
Issues that the hotfix package fixesThis hotfix package fixes the following issues that were not previously documented in a Microsoft Knowledge Base article:You try to open a user’s shared calendar in Outlook 2007. If the user’s mailbox is in a different administrative group, the shared mailbox cannot be synchronized correctly. Additionally, an eventthat resembles the following event is logged in the Application log:
Event Type:Warning
Event Source:MSExchangeSA
Event Category:RFR Interface
Event ID:9234
Date:date
Time:time
User:N/A
Computer:server_name
Description: Referral Interface was not able to find an msExchExchangeServer object with legacyExchangeDN ‘/o=Organization_Name/ou=Exchange Administrative Group (group)/cn=Configuration/cn=Servers/cn=server_name’ in the Active Directory.You use a custom solution in a trusted simple MAPI environment to send e-mail messages in Outlook 2007. If an e-mail message contains more than five recipients, the e-mail aliases are not resolved. Additionally, the Outlook security dialog box unexpectedly appears. You have multiple appointments scheduled for a day in the calendar in Outlook 2007. When you print the calendar in Monthly style, only two appointments are printed for the day.
This issue may occur even though there is sufficient room for all the appointments to print for that day. A delegate for your mailbox accepts a meeting request on your behalf. Then,the meeting is updated. When you view the updated meeting request, the No response required button is not displayed. As meeting requests and meeting updates are processed in Outlook, the tracking status and the attendee changes for the meeting requests may cause new style conflicts.
When this issue occurs, the tracking status and the attendee changes are not updated automatically. Therefore,many items may be added to the “Sync Issues” folder and to the Conflicts folder. You send a meeting request that contains anattendee to which youcannot send requests, such as a meeting room. When you reopen the meeting request, the free/busy time for this attendee is not displayed. You send a recurring meeting request to attendees. Then, you update the meeting time for the recurring meeting and then send the update. When you reopen the recurring meeting, the meeting time reverts to the original meeting time. You open a second instance of a recurring meeting. Then, you update the recurring meeting and then send the update. When you do this, the meeting update is sent as expected. However, the changes to the meeting are not saved. You accept an all-day event request. Then, youschedule another all-day event that spans the same times as theall-day event that you accepted. When you switch between events, theevent that you scheduled may disappear. When you switch to the accepted event and then switch back to the scheduled event, the scheduled event reappears.You delete attendees from a recurring meeting and then send the meeting update. When you do this, the update is sent to all attendees. This includes the deleted attendees. You create a meeting exception for a recurring meeting. Then, you restart Outlook and then open the meeting exception. When you do this, the body of the exception message is blank. You are the organizer of a recurring meeting. When you open the recurring meeting, the meeting opens as a Send Cancellation action. You accept a meeting request in Cached Exchange Mode. When you do this, the meeting request is deleted and the meeting acceptance is not sent. Additionally, you may receive the following error message:

Cannot save free/busy information.You create a meeting exception for a recurring meeting. Then,you reopen the meeting exception. When you do this,one of the following symptoms may occur: If the body of the recurring meeting message is small, the body of theexception message is now large.If the body of the recurring meeting message is large, the body of the exception message is now blank.Note A large message body for a personal folders (.pst) file is 8 kilobytes (KB) or larger.When you try to propose a new time for a meeting request, you receive the following error message:

The end date you entered occurs before the start date.You change an existing meeting request. When you click Save and Send Update, the changes to the meeting request are sent as expected. However, the meeting request closes unexpectedly.

ASP.NET data binding overview

Symptoms
This article provides an introduction to ASP.NET data binding.
For additional ASP.NET overviews, see the following Microsoft Knowledge Base article:
305140?(http://support.microsoft.com/kb/305140/) ASP.NET roadmap
Resolution
With ASP.NET data binding, you can bind any server control to simple properties, collections, expressions and/or methods. When you use data binding, you have more flexibility when you use data from a database or other means.
This article addresses the following data binding topics: Data binding essentials<%# %> SyntaxPage.DataBind() versus Control.DataBind()Data-bound list controlsRepeater controlDataList controlDataGrid controlAccessing dataDataSet dlassDataReader dlassBinding in list control templatesDataBinder.Eval methodExplicit castingItemDataBound event
Data binding essentials<%# %> Syntax ASP.NET introduces a new declarative syntax, <%# %>. This syntax is the basis for using data binding in an .aspx page. All data binding expressions must be contained within these characters. The following list includes examples of simple data binding from multiple sources: Simple property (syntax for a customer):

<%# custID %> Collection (syntax for an order):

<asp:ListBox id=”List1″ datasource=’<%# myArray %>’ runat=”server”> Expression (syntax for a contact):

<%# ( customer.First Name + ” ” + customer.LastName ) %> Method result (syntax for the outstanding balance):

<%# GetBalance(custID) %> In the preceding examples, the inline <%# %> tags indicate where the information from a specific data source is to be placed in the .aspx page. The following data binding example uses a TextBox Web server control:

<asp:textbox id=txt text=”<%# custID %>” runat=server /> For more information about data binding syntax, see the following .NET Framework Software Development Kit (SDK) documentation:
Data Binding Expression Syntax
http://msdn2.microsoft.com/en-us/library/bda9bbfx(vs.71).aspx(http://msdn2.microsoft.com/en-us/library/bda9bbfx(vs.71).aspx)Page.DataBind() versus Control.DataBind() After the particular data sources have been determined and set for the objects on the .aspx page, you must bind the data to these data sources. You can use the Page.DataBind or the Control.DataBind method to bind the data to the data sources.
Both methods work similarly. The main difference is that all data sources are bound to their server controls after the Page.DataBind method is called. No data is rendered to the control until you explicitly call either the DataBind method of the Web server control or until you invoke the page-level Page.DataBind method. Typically, Page.DataBind (or DataBind) is called from the Page_Load event.
For more information about the DataBind method, see the following .NET Framework SDK documentation: Control.DataBind Method
http://msdn.microsoft.com/en-us/library/w5e5992d.aspx(http://msdn.microsoft.com/en-us/library/w5e5992d.aspx)
Data-bound list controls The list controls are special Web server controls that can bind to collections. You can use these controls to display rows of data in a customized template format. All list controls expose the DataSource and the DataMember properties, which are used to bind to collections.
These controls can bind their DataSource property to any collection that supports the IEnumerable, the ICollection, or the IListSource interface.
Repeater control The Repeater control is a templated, data-bound list. The Repeater control is “lookless;” that is, it does not have any built-in layout or styles. Therefore, you must explicitly declare all HTML layout, formatting, and style tags in the control’s templates.
The following code samples demonstrate how you can use one list control, the Repeater control, to display data:
NOTE: You must modify the parameters of the connection string as necessary for your environment.
Visual Basic .NET

<%@ Page Language=”vb” %><%@ Import Namespace=”System.Data” %><%@ Import Namespace=”System.Data.SqlClient” %><script runat=”server”>Sub Page_Load(sender As Object, e As EventArgs)Dim cnn As SqlConnection = New SqlConnection(“server=(local);” & _”database=pubs;Integrated Security=SSPI”)Dim cmd As SqlDataAdapter = New SqlDataAdapter(“select * from authors”, cnn)Dim ds As DataSet = New DataSet()cmd.Fill(ds)Repeater1.DataSource = dsRepeater1.DataBind()End Sub</script><html><body><form id=”Form1″ method=”post” runat=”server”><asp:Repeater id=”Repeater1″ runat=”server”><ItemTemplate><%# DataBinder.Eval(Container.DataItem,”au_id”) %><br> </ItemTemplate></asp:Repeater></form></body></html> Visual C# .NET

<%@ Page language=”c#” %><%@ Import Namespace=”System.Data” %><%@ Import Namespace=”System.Data.SqlClient” %><script runat=”server”>void Page_Load(Object sender, EventArgs e) {SqlConnection cnn = newSqlConnection(“server=(local);database=pubs;Integrated Security=SSPI”);SqlDataAdapter da = new SqlDataAdapter(“select * from authors”, cnn);DataSet ds = new DataSet();da.Fill(ds, “authors”);Repeater1.DataSource = ds.Tables["authors"];Repeater1.DataBind();}</script><html><body><form id=”WebForm2″ method=”post” runat=”server”><asp:Repeater id=”Repeater1″ runat=”server”><ItemTemplate><%# DataBinder.Eval(Container.DataItem,”au_id”) %><br> </ItemTemplate></asp:Repeater></form></body></html> Visual J# .NET

<%@ Page language=”VJ#” %><%@ Import Namespace=”System.Data” %><%@ Import Namespace=”System.Data.SqlClient” %> <script runat=”server”>void Page_Load(Object sender, EventArgs e) {SqlConnection cnn = new SqlConnection(“server=(local);database=pubs;IntegratedSecurity=SSPI”);SqlDataAdapter da = new SqlDataAdapter(“select * from authors”, cnn);DataSet ds = new DataSet();da.Fill(ds, “authors”);DataTableCollection dtc = ds.get_Tables();int index = dtc.IndexOf(“authors”);Repeater1.set_DataSource(dtc.get_Item(index));Repeater1.DataBind();}</script><html><body><form id=”WebForm2″ method=”post” runat=”server”><asp:Repeater id=”Repeater1″ runat=”server”><ItemTemplate><%# DataBinder.Eval(Container.DataItem,”au_id”) %><br></ItemTemplate></asp:Repeater></form></body></html> For more information about the Repeater control, see the following .NET Framework SDK documentation:
Repeater Web Server Control
http://msdn.microsoft.com/en-us/library/x8f2zez5.aspx(http://msdn.microsoft.com/en-us/library/x8f2zez5.aspx)DataList control The DataList class is a feature-rich, templated, data-bound list. You can modify the templates to customize this control. Unlike the Repeater control, DataList supports directional rendering and can optionally render in an HTML table at run time.
For more information about the DataList control, see the following .NET Framework SDK documentation:
DataList Web Server Control
http://msdn.microsoft.com/en-us/library/9cx2f3ks(VS.85).aspx(http://msdn.microsoft.com/en-us/library/9cx2f3ks(VS.85).aspx)DataGrid control The DataGrid control is a fully featured, multicolumn, data-bound grid. To customize the layout of individual columns in the DataGrid, you can set the column type to “templated” and modify the column’s templates. The DataGrid control can render without templates, which makes this control ideal for reporting scenarios. DataGrid also supports selection, editing, deletion, paging, and sorting by column and button columns.
For more information about the DataGrid control, see the following .NET Framework SDK documentation:
DataGrid Web Server Control
http://msdn.microsoft.com/en-us/library/aa710742(VS.71).aspx(http://msdn.microsoft.com/en-us/library/aa710742(VS.71).aspx)
Accessing data This section describes how to access data from a database and bind the data to list controls. You can use the DataSet or the DataReader class to obtain data from a database. DataSet class A DataSet contains a complete representation of data, including the table structure, the relationships between tables, and the ordering of the data. DataSet classes are flexible enough to store any kind of information from a database to an Extensible Markup Language (XML) file. DataSet classes are stateless; that is, you can pass these classes from client to server without tying up server connection resources. The following code demonstrates how to use a DataSet to bind data to a control:
NOTE: You must modify the parameters of the connection string as necessary for your environment.
Visual Basic .NET

Dim cnn As SqlConnection = New SqlConnection(“server=(local);” & _”database=pubs;Integrated Security=SSPI”)Dim cmd As SqlDataAdapter = New SqlDataAdapter(“select * from authors”, cnn)Dim ds As DataSet = New DataSet()cmd.Fill(ds)MyRepeater.DataSource = dsMyRepeater.DataBind() Visual C# .NET

SqlConnection cnn = new SqlConnection(“server=(local);database=pubs;Integrated Security=SSPI”); SqlDataAdapter da = new SqlDataAdapter(“select * from authors”, cnn); DataSet ds = new DataSet(); da.Fill(ds);MyRepeater.DataSource = ds;MyRepeater.DataBind(); Visual J# .NET

SqlConnection cnn = new SqlConnection(“server=(local);database=pubs;Integrated Security=SSPI”); SqlDataAdapter da = new SqlDataAdapter(“select * from authors”, cnn); DataSet ds = new DataSet(); da.Fill(ds); MyRepeater.set_DataSource(ds);MyRepeater.DataBind(); For more information about the DataSet class, see the following .NET Framework SDK documentation:
DataSet Class
http://msdn2.microsoft.com/en-us/library/system.data.dataset(vs.71).aspx(http://msdn2.microsoft.com/en-us/library/system.data.dataset(vs.71).aspx)DataReader class Conversely, if you only need to display (and not change) the data that is to be rendered, a DataReader class may be a better solution. For example, it is better to use a DataReader for a DropDownList control because the DataReader is a forward-only data cursor. The following code demonstrates how to use a SqlDataReader class to bind data to a control:
Visual Basic .NET

Dim cnn As SqlConnection = New SqlConnection(“server=(local);” & _”database=pubs;Integrated Security=SSPI”)Dim cmd As SqlCommand = New SqlCommand(“select * from authors”, cnn)cnn.Open()MyRepeater.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection)MyRepeater.DataBind() Visual C# .NET

SqlConnection cnn = new SqlConnection(“server=(local);database=pubs;Integrated Security=SSPI”);SqlCommand cmd = new SqlCommand(“select * from authors”, cnn);cnn.Open();MyRepeater.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection);MyRepeater.DataBind(); Visual J# .NET

SqlConnection cnn = new SqlConnection(“server=(local);database=pubs;Integrated Security=SSPI”); SqlCommand cmd = new SqlCommand(“select * from authors”, cnn); cnn.Open();MyRepeater.set_DataSource(cmd.ExecuteReader(CommandBehavior.CloseConnection));MyRepeater.DataBind(); For more information about the SqlDataReader class and data access with ASP.NET, see the following topics in the .NET Framework SDK documentation:
SqlDataReader Class
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.aspx(http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.aspx)
Developing High-Performance ASP.NET Applications
http://msdn2.microsoft.com/en-us/library/5dws599a(vs.71).aspx(http://msdn2.microsoft.com/en-us/library/5dws599a(vs.71).aspx)
Binding in list control templates You can use templates in the list controls to bind and to customize individual records of a data source. This section includes three methods to do this. DataBinder.Eval method When the data source works with data that is returned from a database, the data source may contain numerous pieces of information. You can use the generic DataBinder.Eval method to return data. In the following code sample, the “au_id” field is returned from the data source of the container object:

<%# DataBinder.Eval(Container.DataItem,”au_id”) %> For more information about the DataBinder.Eval method, see the following .NET Framework SDK documentation:
DataBinder.Eval Method
http://msdn.microsoft.com/en-us/library/4hx47hfe.aspx(http://msdn.microsoft.com/en-us/library/4hx47hfe.aspx)Explicit casting If you need more control, use explicit casting. An explicit conversion uses a type conversion keyword. These keywords act as functions, but the compiler generates the code inline. Therefore, execution is slightly faster than with a function call. The following code samples use explicit casting:
Visual Basic .NET

‘ DataTable as the DataSource<%# CType(Container.DataItem, System.Data.DataRowView)(“au_id”) %>’ DataReader as the DataSource<%# CType(Container.DataItem, System.Data.Common.DbDataRecord)(“au_id”) %>’ DataReader as the DataSource<%# CType(Container.DataItem, System.Data.Common.DbDataRecord)(0) %> Visual C# .NET

// DataTable as the DataSource<%# ((System.Data.DataRowView)Container.DataItem)["au_id"] %> // DataReader as the DataSource<%# ((System.Data.Common.DbDataRecord)Container.DataItem)["au_id"] %>// DataReader as the DataSource<%# ((System.Data.Common.DbDataRecord)Container.DataItem)[0] %> Visual J# .NET

// DataTable as the DataSource<%# ((System.Data.DataRowView)Container.DataItem)["au_id"] %> // DataReader as the DataSource<%# ((System.Data.Common.DbDataRecord)Container.DataItem)["au_id"] %>// DataReader as the DataSource<%# ((System.Data.Common.DbDataRecord)Container.DataItem)[0] %> Note that the preceding samples use either a DataTable, which is a subset of a DataSet, or DataReader as a data source. ItemDataBound event You can also use the ItemDataBound event of the control to bind the data. This event occurs when an item is data bound to the control. The following HTML code sample defines a Repeater control with an ItemTemplate:

<asp:repeater id=rptr runat=server><itemtemplate><asp:label id=lblAuthorID runat=server /></itemtemplate></asp:repeater> The following methods are required in your page:
Visual Basic .NET

public Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)’TODO: Retrieve data from a database,’and bind the data to a list control.End Subpublic Sub rptr_OnItemDataBound(ByVal sender As Object, _ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptr.ItemDataBoundDim rec As DataRowViewrec = e.Item.DataItem’Make sure that you have the data.If Not IsDBNull(rec) ThenDim l1 As Labell1 = e.Item.FindControl(“lblAuthorID”)l1.Text = rec(“au_id”).ToString()End IfEnd Sub Visual C# .NET

public void Page_Init(object sender, System.EventArgs e){rptr.ItemDataBound += new RepeaterItemEventHandler(rptr_OnItemDataBound);}public void Page_Load(object sender, System.EventArgs e){// TODO: Retrieve data from a database,// and bind the data to a list control.}public void rptr_OnItemDataBound(object sender, RepeaterItemEventArgs e){System.Data.Common.DbDataRecord rec = (System.Data.Common.DbDataRecord)e.Item.DataItem;if(rec!=null) //Make sure that you have the data.{Label l1 = (Label)e.Item.FindControl(“lblAuthorID”);l1.Text = rec["au_id"].ToString();}} Visual J# .NET

public void Page_Init(Object sender, System.EventArgs e){rptr.add_ItemDataBound(new RepeaterItemEventHandler(rptr_OnItemDataBound));}private void Page_Load(Object sender, System.EventArgs e){// TODO: Retrieve data from a database,// and bind the data to a list control.}public void rptr_OnItemDataBound(Object sender, RepeaterItemEventArgs e){System.Data.Common.DbDataRecord rec = (System.Data.Common.DbDataRecord)e.get_Item().get_DataItem();if (rec != null) //Make sure that you have the data.{Label l1 = (Label)e.get_Item().FindControl(“lblAuthorID”);l1.set_Text(((rec.get_Item(“au_id”)).ToString()));}}