473,480 Members | 1,847 Online
Bytes | Software Development & Data Engineering Community
Create 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="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load
Dim cnn As SqlConnection
Dim cmd As SqlCommand
cnn = New SqlConnection("server=(local);trusted_connection=y es;database=pubs")
cmd = New SqlCommand("select au_lname from authors",cnn)
cnn.Open()
rptr.DataSource = cmd.ExecuteReader()
rptr.DataBind()
cnn.Close()
lbl.Text += "Page_Load "
End Sub
Sub ItemCommand(s As Object, e As RepeaterCommandEventArgs)
lbl.Text += "ItemCommand "
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 2916
It's OK. I shouldn't have called DataBind on postback.

"Rob Rutherford" <ro*@xyz.invalid> wrote in message news:cv**********@newsg1.svr.pol.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="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load
Dim cnn As SqlConnection
Dim cmd As SqlCommand
cnn = New SqlConnection("server=(local);trusted_connection=y es;database=pubs")
cmd = New SqlCommand("select au_lname from authors",cnn)
cnn.Open()
rptr.DataSource = cmd.ExecuteReader()
rptr.DataBind()
cnn.Close()
lbl.Text += "Page_Load "
End Sub
Sub ItemCommand(s As Object, e As RepeaterCommandEventArgs)
lbl.Text += "ItemCommand "
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
9786
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...
0
1393
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...
0
6103
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...
3
5658
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...
3
10902
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...
2
4856
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...
0
1045
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...
1
1832
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...
2
4643
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...
0
7055
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
7059
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
7010
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...
0
5362
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,...
0
4499
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...
0
3011
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...
0
3003
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1311
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 ...
0
203
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...

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.