473,546 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.as p
--------------------
<%@ Page Language="vb" AutoEventWireup ="false" Codebehind="Tes tRepeater.aspx. vb" Inherits="MM200 3.TestRepeater" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD ><title>TestRep eater</title><meta name="GENERATOR " content="Micros oft Visual Studio .NET 7.1"><meta name="CODE_LANG UAGE" content="Visual Basic .NET 7.1"><meta name="vs_defaul tClientScript" content="JavaSc ript"><meta name="vs_target Schema" content="http://schemas.microso ft.com/intellisense/ie5"></HEAD><body><for m id="Form1" method="post" runat="server"> <P><asp:Label id="lblMessage " runat="server"> </asp:Label></P><asp:Repeate r id="rptWOTime" runat="server" OnItemDataBound ="rptWOTime_Ite mDataBound"><It emTemplate><asp :Literal ID="litWOTime" Runat=server></asp:Literal></ItemTemplate></asp:Repeater></form></body></HTML

TestRepeater.as px.v
------------------------
Imports System.Dat
Imports System.Data.Com mo
Imports System.Data.Sql Clien

Public Class TestRepeate
Inherits System.Web.UI.P ag

#Region " Web Form Designer Generated Code

'This call is required by the Web Form Designer
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent(

End Su
Protected WithEvents rptWOTime As System.Web.UI.W ebControls.Repe ate
Protected WithEvents lblMessage As System.Web.UI.W ebControls.Labe

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

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

#End Regio

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) 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(S ession("MMWACon nStr")

strWork = "select convert(char,Da teOfService,101 ) as DateOfService, " &
"TimeIn, HoursWorked, " &
"isnull(LastNam e,'') as LastName, isnull(FirstNam e,'') as FirstName, " &
"isnull(WorkPer formedName,'') as WorkPerformedNa me, " &
"isnull(LaborNo tes,'') as LaborNotes " &
"from " & Session("MMWADB Name") & "..tblWOHou rs hours " &
"left outer join " & Session("MMWADB Name") & "..tblTechnicia ns techs " &
"on techs.TechID = hours.TechID " &
"left outer join " & Session("MMWADB Name") & "..tblCBO_WorkP erformed wp " &
"on wp.WorkPerforme dID = hours.WorkPerfo rmedID " &
"where WONum = " & strWONum & " and " &
"PatriotAccount ID = '" & strAccountID & "' " &
"order by DateOfService, TimeIn

conMM.Open(
cmdMM = New SqlCommand(strW ork, conMM
dtrMM = cmdMM.ExecuteRe ader(

lblMessage.Text = strWor

If Not dtrMM.Read The
lblMessage.Text &= "<br><br>No records found"
Else
lblMessage.Text &= "<br><br>Record s were found"
rptWOTime.DataS ource = dtrMM
rptWOTime.DataB ind()
End If
dtrMM.Close()
conMM.Close()
End Sub

Sub rptWOTime_ItemD ataBound(ByVal sender As Object, ByVal e As RepeaterItemEve ntArgs)
If e.Item.ItemType = ListItemType.It em Or _
e.Item.ItemType = ListItemType.Al ternatingItem Then
Dim dbr As DbDataRecord = CType(e.Item.Da taItem, DbDataRecord)
Dim litWOTime As Literal = e.Item.FindCont rol("litWOTime" )
litWOTime.Text = dbr("DateOfServ ice") & "<BR>"
End If
End Sub

End Class

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

<asp:Repeater OnItemDataBound ="rptWOTime_Ite mDataBound"
....>...</asp:Repeater>

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

Sub rptWOTime_ItemD ataBound(ByVal sender As Object, ByVal e As
RepeaterItemEve ntArgs) Handles rptWOTime.ItemD ataBound
...
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******@4guysf romrolla.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
1707
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. Each row has a text box for quantity to order and a button to add the product and quantity to the shopping cart. I can dynamically assign the...
0
6124
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 dynamically (something I need to do for my application). The problem is that when I click on the button in the repeater the ItemCommand event does not seem...
2
4862
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 that the ItemCommand event is not firing the first time the LinkButton is clicked. 2nd-(n)times after it's fine but the FIRST time it's clicked I get...
1
2310
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 my case the employees' details should be displayed in Alphabetical order.The employee names starting with "A" should display two extra HTML rows...
4
1602
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 #Container.DataItem("LINE53")<>2 THEN%> <td width="300" colspan="3"><font size="2" face="Verdana, Arial, Helvetica,
2
3702
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 related to the row. I can't find a good control for this in ASP.Net 2.0. Now I use a repeater and check the checkbox on ItemDataBound, I also fill the...
1
7313
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 'OnSelectedIndexChanged' subroutine, and 2) for that subroutine to be able to somehow identify which 'row' of the repeater the dropdownlist belongs to. To keep...
2
3731
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 postback happen appropriately. The DropDownList looks like this: <asp:DropDownList id="ddMultiQty"...
2
1464
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 <asp:DataList ID="dlData" runat="server" DataKeyField="prod_doc_id" EnableViewState=true RepeatColumns=3 RepeatDirection=Horizontal OnItemCommand="DoThis">...
0
7504
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7435
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7694
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7792
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6026
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5080
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3491
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3470
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.