473,396 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Repeater DataItemBound not firing

I am trying use a repeater to process through the results of a sql query and produce a table that may or may not have multiple rows per record in the query, depending upon whether the technicians have added notes to their work. I can not get the OnItemDataBound event to fire for the repeater control. I have created a scaled-down version of what it is that I am trying to accomplish just to make it easier to read. This does not work either. The code was based on MSKB article 317429. The trimmed down code should do nothing more that list the first data item in each record down the page

Just to eliminate potential problems, I did write the sql command out to the screen as well. I then cut and paste the code into the Query Analyzer to make sure that it was not an issue with the query itself

TestRepeater.asp
--------------------
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="TestRepeater.aspx.vb" Inherits="MM2003.TestRepeater"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><title>TestRepeater</title><meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"><meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"><meta name="vs_defaultClientScript" content="JavaScript"><meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"></HEAD><body><form id="Form1" method="post" runat="server"><P><asp:Label id="lblMessage" runat="server"></asp:Label></P><asp:Repeater id="rptWOTime" runat="server" OnItemDataBound="rptWOTime_ItemDataBound"><ItemTem plate><asp:Literal ID="litWOTime" Runat=server></asp:Literal></ItemTemplate></asp:Repeater></form></body></HTML

TestRepeater.aspx.v
------------------------
Imports System.Dat
Imports System.Data.Commo
Imports System.Data.SqlClien

Public Class TestRepeate
Inherits System.Web.UI.Pag

#Region " Web Form Designer Generated Code

'This call is required by the Web Form Designer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent(

End Su
Protected WithEvents rptWOTime As System.Web.UI.WebControls.Repeate
Protected WithEvents lblMessage As System.Web.UI.WebControls.Labe

'NOTE: The following placeholder declaration is required by the Web Form Designer
'Do not delete or move it
Private designerPlaceholderDeclaration As System.Objec

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Ini
'CODEGEN: This method call is required by the Web Form Designe
'Do not modify it using the code editor
InitializeComponent(
End Su

#End Regio

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
Dim conMM As SqlConnectio
Dim cmdMM As SqlComman
Dim dtrMM As SqlDataReade
Dim strWork As Strin
Dim strWONum As String = "6958
Dim strAccountID As String = "SAMP

conMM = New SqlConnection(Session("MMWAConnStr")

strWork = "select convert(char,DateOfService,101) as DateOfService, " &
"TimeIn, HoursWorked, " &
"isnull(LastName,'') as LastName, isnull(FirstName,'') as FirstName, " &
"isnull(WorkPerformedName,'') as WorkPerformedName, " &
"isnull(LaborNotes,'') as LaborNotes " &
"from " & Session("MMWADBName") & "..tblWOHours hours " &
"left outer join " & Session("MMWADBName") & "..tblTechnicians techs " &
"on techs.TechID = hours.TechID " &
"left outer join " & Session("MMWADBName") & "..tblCBO_WorkPerformed wp " &
"on wp.WorkPerformedID = hours.WorkPerformedID " &
"where WONum = " & strWONum & " and " &
"PatriotAccountID = '" & strAccountID & "' " &
"order by DateOfService, TimeIn

conMM.Open(
cmdMM = New SqlCommand(strWork, conMM
dtrMM = cmdMM.ExecuteReader(

lblMessage.Text = strWor

If Not dtrMM.Read The
lblMessage.Text &= "<br><br>No records found"
Else
lblMessage.Text &= "<br><br>Records were found"
rptWOTime.DataSource = dtrMM
rptWOTime.DataBind()
End If
dtrMM.Close()
conMM.Close()
End Sub

Sub rptWOTime_ItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem Then
Dim dbr As DbDataRecord = CType(e.Item.DataItem, DbDataRecord)
Dim litWOTime As Literal = e.Item.FindControl("litWOTime")
litWOTime.Text = dbr("DateOfService") & "<BR>"
End If
End Sub

End Class

Nov 18 '05 #1
1 3274
Chances are the event handler (rptWOTime_ItemDataBound) is not wired up
to the Repeater's ItemDataBound event. One way to do this is to add
OnItemDataBound="rptWOTime_ItemDataBound" in the declarative syntax of
the Repeater control:

<asp:Repeater OnItemDataBound="rptWOTime_ItemDataBound"
....>...</asp:Repeater>

Another option is to add the Handles keyword to the event handler
declaration:

Sub rptWOTime_ItemDataBound(ByVal sender As Object, ByVal e As
RepeaterItemEventArgs) Handles rptWOTime.ItemDataBound
...
End Sub

If you are using VS.NET, you can automatically get the Handles keyword
added by selecting the repWOTime item in the DropDownList at the top of
the code-behind class, and then in the other DropDownList, picking the
ItemDataBound event.

hth
--

Scott Mitchell
mi******@4guysfromrolla.com
http://www.4GuysFromRolla.com
http://www.ASPFAQs.com
http://www.ASPMessageboard.com

* When you think ASP, think 4GuysFromRolla.com!
Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: bob garbados | last post by:
I need to create a page that displays all of the products from a table and allows for add to cart functionality. My thoughts were to display all of the products in table rows using a repeater. ...
0
by: Michael | last post by:
I've seen several posts relating to this problem, and tried EnableViewState="False", but it does not work for me. A twist in my problem is that I am adding the templates for the repeater...
2
by: Curt_C [MVP] | last post by:
I've got a Repeater and within it a LinkButton. The LinkButton has an CommandName="Test" In the Repeater's ItemCommand event I want to check for this command name but the problem I'm having is...
1
by: Kas_aspnet | last post by:
Hi, I have to display a sequence of records in an Aspx page. The problem is, i have to display the records by checking conditions like Classic ASP. For example, consider an employee table. In...
4
by: kelvinweb | last post by:
Hi All, My Source Code is the following <ItemTemplate> <tr> <td width="100" align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;</font></td> <%IF...
2
by: RichardH | last post by:
Hi, I have x number of table rows that all should have a checkbox and a dropdownlist on each row. The checkbox could be checked and the dropdown should contain y number of values that are...
1
by: champ.supernova | last post by:
Hi, I have a dropdownlist which is repeated inside a repeater. What I'm wanting is for when one instance of the dropdownlist has its selection changed, for 1) this to trigger an...
2
by: MattB | last post by:
I have a (.Net 1.1) form with a Repeater and a DropDownList in the ItemTemplate. I programmatically make the DDL Autopostback = true at runtime based on the bound data. That works - I can see the...
2
by: praveenkhade | last post by:
I got a prob I am using a repeater to display the product docs. M using OnItemCommand but its not firing. can u tell me wat might be the prob, I made viewstate as enable. Plz help me ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.