473,606 Members | 2,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Repeater - ItemCommand and EnableViewState

I have a Repeater on an ASP.NET page. If I click a Button in the Repeater,
the Repeater's ItemCommand event fails to fire. If anyone can explain why
it doesn't fire I'd be grateful. Here's the code.

<%@ Page Language="VB" %>
<%@ import Namespace="Syst em.Data.SqlClie nt" %>
<script runat="server">
Sub Page_Load
Dim cnn As SqlConnection
Dim cmd As SqlCommand
cnn = New SqlConnection(" server=(local); trusted_connect ion=yes;databas e=pubs")
cmd = New SqlCommand("sel ect au_lname from authors",cnn)
cnn.Open()
rptr.DataSource = cmd.ExecuteRead er()
rptr.DataBind()
cnn.Close()
lbl.Text += "Page_Load "
End Sub
Sub ItemCommand(s As Object, e As RepeaterCommand EventArgs)
lbl.Text += "ItemComman d "
End Sub
</script>
<html>
<body>
<form runat="Server">
<asp:Label id="lbl" runat="server" EnableViewState ="false"/>
<asp:Repeater id="rptr" runat="Server" OnItemCommand=" ItemCommand">
<HeaderTemplate >
<asp:Button runat="server"/>
</HeaderTemplate>
</asp:Repeater>
</form>
</body>
</html>


Nov 19 '05 #1
1 2940
It's OK. I shouldn't have called DataBind on postback.

"Rob Rutherford" <ro*@xyz.invali d> wrote in message news:cv******** **@newsg1.svr.p ol.co.uk...
I have a Repeater on an ASP.NET page. If I click a Button in the Repeater,
the Repeater's ItemCommand event fails to fire. If anyone can explain why
it doesn't fire I'd be grateful. Here's the code.

<%@ Page Language="VB" %>
<%@ import Namespace="Syst em.Data.SqlClie nt" %>
<script runat="server">
Sub Page_Load
Dim cnn As SqlConnection
Dim cmd As SqlCommand
cnn = New SqlConnection(" server=(local); trusted_connect ion=yes;databas e=pubs")
cmd = New SqlCommand("sel ect au_lname from authors",cnn)
cnn.Open()
rptr.DataSource = cmd.ExecuteRead er()
rptr.DataBind()
cnn.Close()
lbl.Text += "Page_Load "
End Sub
Sub ItemCommand(s As Object, e As RepeaterCommand EventArgs)
lbl.Text += "ItemComman d "
End Sub
</script>
<html>
<body>
<form runat="Server">
<asp:Label id="lbl" runat="server" EnableViewState ="false"/>
<asp:Repeater id="rptr" runat="Server" OnItemCommand=" ItemCommand">
<HeaderTemplate >
<asp:Button runat="server"/>
</HeaderTemplate>
</asp:Repeater>
</form>
</body>
</html>



Nov 19 '05 #2

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

Similar topics

1
9798
by: Mark Fox | last post by:
Hello, I have a repeater and in each itemtemplate I have a radiobuttonlist. I am attempting to figure out how on postback I could iterate through the rows displayed by the repeater and for each row grab the selected value of the radio button list. When is the Repeater.Items collection populated? I first attempted to access the Repeater.Items collection from the Command event of a normal linkbutton on the page, but it was empty. Is...
0
1405
by: Sparhawk | last post by:
I got a weird problem with a repeater. The Repeater has an ImageButton in its ItemTemplate. The Repeater has an ItemCommand defined. If the user clicks one of the buttons, nothing happens. If he clicks again, after postback, the ItemCommand is raised like it is supposed to do. This behavior is reproducible.
0
6144
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 to be fired. Can anyone tell me what I am doing wrong? //////////////WebForm1.aspx: <%@ Page...
3
5669
by: Leigh Webber | last post by:
I have an HTMLAnchor control on my aspx page. When it's not inside a repeater, it works fine. When I put it inside a repeater control, the handler never gets fired. I have a handler for the htmlAnchor's ServerClick event (works when not inside a repeater), and a handler for the repeater's ItemCommand event. My html and vb source code is shown below, but what I think I need is a simple working example in vb.net. Can anyone help?...
3
10917
by: Joel Daniels | last post by:
Hello, I am trying to determine the proper way to access the underlying data row for a Repeater item in the ItemCommand event. In the page load event, I bind the Repeater data source to a SqlDataReader. I check for !IsPostBack so the data binding only happens the first time. In the ItemCommand event, e.Item.DataItem is unassigned. Any suggestions? Thanks!
2
4871
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 nothing. The repeater is on an ASCX control that's on a standard ASPX page.
0
1050
by: Demetri | last post by:
Guys, If you have a repeater and EnableViewState is false and the repeater has a checkbox control in each item and alternating item (row) how do you capture which checkboxes were checked by the user on postback (think hotmail)? EnableViewState = false is a requirement and no execeptions can be made. Any clues?
1
1840
by: Doogie | last post by:
Hi, I have been trying to get a checkbox added to a repeater control of mine and then try to access events of the repeater control when a user clicks the checkbox. At first, since the control is tied to xsl, I added the checkbox there. That works fine, but I cannot get any information about the checkbox (i.e. checked, unchecked, etc) when I pass data from the xsl over to a method in java. I can get info on the other columns but not...
2
4651
by: Nathan Sokalski | last post by:
I have an ImageButton inside a Repeater control. However, the ImageButton does not trigger the Repeater's ItemCommand event. For the moment, I am nesting an Image control inside a LinkButton, which works, but requires more work and 2 controls. I believe the reason for this is that the ImageButton renders an <input type="image"/while the LinkButton renders an <a></a> tag. Any ideas? -- Nathan Sokalski njsokalski@hotmail.com...
0
8015
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7951
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8430
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8305
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6770
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5966
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2448
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1296
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.