Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 27th, 2005, 11:19 AM
Authorized User
 
Join Date: Dec 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to datagram Send a message via AIM to datagram
Default Strange REPEATER Error????

I am trying to use a button in my Repeating table. The only thing I can get to work is the "LinkButton". The normal "Button" will not work. Maybe because the Link button uses Javascript to post back? I have no idea. Here is the code:

<asp:repeater OnItemCommand="Repeater1_ItemCommand" id=Repeater1 runat="server" DataSource="<%# DataSet11 %>" DataMember="tbl_lmedata_labor">

<ItemTemplate>
<asp:Button id="Button2" runat="server" CommandName="Delete"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "labor_id") %>' Text="Delete"></asp:Button>



That does not work. What works, is this:

<asp:LinkButton ID="Linkbutton1" Runat="server" CommandName="Delete"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "labor_id") %>'>
Delete Customer
</asp:LinkButton>




Here is the Code Behind:

Protected Sub Repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs )
        Dim hello As Integer = e.CommandArgument
        TextBox1.Text = hello


 
Old June 1st, 2005, 06:56 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Can you further describe "does not work"? Do you get an error or is the page rendering but not behaving as expected?

-Peter
 
Old June 1st, 2005, 08:54 AM
Authorized User
 
Join Date: Dec 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to datagram Send a message via AIM to datagram
Default

This code:

<asp:repeater OnItemCommand="Repeater1_ItemCommand" id=Repeater1 runat="server" DataSource="<%# DataSet11 %>" DataMember="tbl_lmedata_labor">

<ItemTemplate>
<asp:Button id="Button2" runat="server" CommandName="Delete"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "labor_id") %>' Text="Delete"></asp:Button>


Does not work. I click the button, and it does nothing.
 
Old June 7th, 2005, 12:38 PM
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi, did you find the answer to this behavior?

Quote:
quote:Originally posted by datagram
 I am trying to use a button in my Repeating table. The only thing I can get to work is the "LinkButton". The normal "Button" will not work. Maybe because the Link button uses Javascript to post back? I have no idea. Here is the code:

<asp:repeater OnItemCommand="Repeater1_ItemCommand" id=Repeater1 runat="server" DataSource="<%# DataSet11 %>" DataMember="tbl_lmedata_labor">

<ItemTemplate>
<asp:Button id="Button2" runat="server" CommandName="Delete"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "labor_id") %>' Text="Delete"></asp:Button>



That does not work. What works, is this:

<asp:LinkButton ID="Linkbutton1" Runat="server" CommandName="Delete"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "labor_id") %>'>
Delete Customer
</asp:LinkButton>




Here is the Code Behind:

Protected Sub Repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs )
        Dim hello As Integer = e.CommandArgument
        TextBox1.Text = hello


 
Old June 7th, 2005, 12:54 PM
Authorized User
 
Join Date: Dec 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to datagram Send a message via AIM to datagram
Default

no :(

 
Old June 7th, 2005, 06:28 PM
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Angie, for my case the LinkButton does not work. Im using VS 2003 on XP (professional). The link button make the post-back, but it seems that on the server side the event method is never found.

 
Old June 8th, 2005, 08:59 AM
Authorized User
 
Join Date: Dec 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to datagram Send a message via AIM to datagram
Default

Wow thats strange. Post to me your vb code behind and I will look at it. Make sure you have your command name & command argument declared in the HTML code. This is what I had and it worked fine:


<asp:LinkButton ID="Linkbutton1" Runat="server" CommandName="Delete"
CommandArgument='<%# DataBinder.Eval(Container.DataItem, "labor_id") %>'>
Delete Customer
</asp:LinkButton>


Here is the Code Behind:

Protected Sub Repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs )
        Dim hello As Integer = e.CommandArgument
        TextBox1.Text = hello

 
Old June 8th, 2005, 01:22 PM
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm modifying a demo example from http://www.dotlucene.net/download/Do...chDemo-1.1.zip

I'm trying to make the paging using a repeater control

by now Im testing the demo inseting a LinkButton in the repeater

<P><asp:repeater id=Repeater1 runat="server" DataSource="<%# Results %>" OnItemCommand="Repeater1_ItemCommand">
                    <ItemTemplate>
                        <p><a href='<%# DataBinder.Eval(Container.DataItem, "path") %>' class="link"><%# DataBinder.Eval(Container.DataItem, "title") %></a><br>
                            <span class="sample">
                                <%# DataBinder.Eval(Container.DataItem, "sample") %>
                            </span>
                            <br>
                            <span class="path">
                                <%# DataBinder.Eval(Container.DataItem, "path") %>
                            </span>
                        </p>
                        <asp:LinkButton id="LinkButton1" runat="server" CommandName="ShowIt" CommandArgument="123" EnableViewState=True Enabled="true"><%# DataBinder.Eval(Container.DataItem, "title") %></asp:LinkButton>
                    </ItemTemplate>
                </asp:repeater>
            </P>

on the code behind:

protected void Repeater1_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
        {
            Response.Write("Hola Mundo");
        }
but the program never go to thise method

I found the following link

http://weblogs.asp.net/jgalloway/arc.../07/30924.aspx

but the options presented there dont work

I foun another example on

http://msdn.microsoft.com/library/de...mmandtopic.asp

Note that in this example they have

AutoEventWireup="True" on the page statement

finally i found the folloing note on

http://msdn.microsoft.com/library/de...rdcontrols.asp

Note If you call the DataBind method of the parent control (the DataList, Repeater, or DataGrid control), the ItemCommand event is not raised, because the contents of the parent control are reset. Therefore, you generally do not want to call the DataBind method on each round trip (that is, in the page initialization without checking for a post back). For details, see Data Binding Multi-Record Web Server Controls and Data Binding Single-Value Web Server Controls at Design Time.


I wonder if somebody else have the same/similar problem?
 
Old June 9th, 2005, 09:46 AM
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think I found an answer here

CreateChildControls before LoadViewState = Bug in DataGrid and Repeater
http://www.pcreview.co.uk/forums/thread-1284042.php


 
Old June 14th, 2005, 01:03 PM
Authorized User
 
Join Date: Dec 2004
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to datagram Send a message via AIM to datagram
Default

In regards to the link, the same thing happens to me with the button. Its like its not posting back or something. But the link button works fine!






Similar Threads
Thread Thread Starter Forum Replies Last Post
strange error Iguchi Visual Studio 2008 1 April 11th, 2008 06:21 AM
An Strange Error alirezaaali Classic ASP Professional 1 August 16th, 2007 10:03 AM
Strange ERROR (?) myself Classic ASP Basics 16 June 22nd, 2006 06:39 AM
Strange Error !!! NinaWilliam ASP.NET 1.0 and 1.1 Basics 2 May 21st, 2006 01:34 AM
Strange error eraser Classic ASP Basics 3 September 21st, 2004 07:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.