Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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
  #1 (permalink)  
Old February 13th, 2007, 12:39 PM
Authorized User
 
Join Date: Apr 2006
Location: Virginia Beach, VA, USA.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot get Edit Template event to fire

The code displays the data but when I click the edit button it appears to simply refresh the existing ItemTemplate page. What book and chapter has a detailed example about DataList templates? I think I have most of your books.

This is the code that will not bring up the EditItem Template.

<asp:DataList ID="DataList1" runat="server" DataKeyField="C_ID" DataSourceID="SqlDataSource1" Width="259px">
<ItemTemplate>
C_ID:<asp:Label ID="C_IDLabel" runat="server" Text='<%# Eval("C_ID") %>'></asp:Label><br />
C_CompanyName:
<asp:Label ID="C_CompanyNameLabel" runat="server" Text='<%# Eval("C_CompanyName") %>'></asp:Label><br />
C_State:
<asp:Label ID="C_StateLabel" runat="server" Text='<%# Eval("C_State") %>'></asp:Label><br />
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit">LinkButton</asp:LinkButton><br />
</ItemTemplate>
<EditItemTemplate>
C_ID:
<asp:TextBox ID="C_IDTextBox" runat="server" Text='<%# Eval("C_ID") %>'></asp:TextBox><br />
C_CompanyName:
<asp:TextBox ID="C_CompanyNameTextBox" runat="server" Text='<%# Bind("C_CompanyName") %>'></asp:TextBox><br />
C_State:
<asp:TextBox ID="C_StateTextBox" runat="server" Text='<%# Eval("C_State") %>'></asp:TextBox><br />
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="Update">LinkButton</asp:LinkButton>&nbsp;
            <asp:LinkButton ID="LinkButton3" runat="server" CommandName="Cancel">LinkButton</asp:LinkButton><br />
            &nbsp;
</EditItemTemplate>
</asp:DataList>

CODE BEHIND
public partial class admin_DataListBeta001 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void DataList1_EditCommand( object source, DataListCommandEventArgs e )
    {
        DataList1.EditItemIndex = e.Item.ItemIndex;
        DataBind();

    }

}

  #2 (permalink)  
Old February 13th, 2007, 01:13 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

is that DataBind ok there???

what happend if you take that out???

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
  #3 (permalink)  
Old February 13th, 2007, 01:42 PM
Authorized User
 
Join Date: Apr 2006
Location: Virginia Beach, VA, USA.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for the reply.

Tried taking it out (DataBind();), no change. What I don't understand is 1) should the Edit button be a linkbutton or just a plain button? and 2) what actually fires the event telling the EditItem Template to load? I can't believe I am having this much trouble with a simple edit page.

  #4 (permalink)  
Old February 13th, 2007, 02:34 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

maybe this link can help you..
http://www.asp.net/learn/dataaccess/....aspx?tabid=63

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
  #5 (permalink)  
Old February 13th, 2007, 03:29 PM
Authorized User
 
Join Date: Apr 2006
Location: Virginia Beach, VA, USA.
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Exactly what I have been looking for, thank you,



Similar Threads
Thread Thread Starter Forum Replies Last Post
Explain the event fire in Gridview? venkatu2005 ASP.NET 1.0 and 1.1 Basics 3 April 8th, 2008 08:41 AM
Unable to fire a click event rfinks ASP.NET 1.0 and 1.1 Basics 2 September 1st, 2006 10:26 PM
SelectedIndexChanged Event doesn't fire ddudley3 ASP.NET 2.0 Professional 7 February 6th, 2006 10:47 AM
Can't fire button event more than 1 time goatstudio ASP.NET 2.0 Basics 4 September 22nd, 2004 07:45 AM





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