Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 June 4th, 2003, 08:38 AM
Registered User
 
Join Date: Jun 2003
Location: Galveston, TX, USA.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Hidden template buttons

I'm using the datagrid and template approach to edit and add new records to a database. After selecting criteria, I present the datagrid template with Edit and Delete buttons. Upon clicking an Add New Record button, I want to make the template footer visible where the person can add a new record.

My problem is that I also want to make the Edit and Delete buttons invisible during this time of adding a new record.

Here's my button which starts the add process:

    <p><asp:button
     id="btnAdd"
     Visible="false"
     OnClick="ShowAdd"
     Text="Add new record"
     BackColor="#79C4DD"
     Runat="server"/></p>

Here's the template columns where the buttons are defined:

          <asp:TemplateColumn HeaderText="">
            <ItemTemplate>
              <asp:Button id="btnEdit" CommandName="Edit" Text=" Edit " Size="12"
                   BackColor="#79C4DD" runat="server"/>
            </ItemTemplate>
            <EditItemTemplate>
              <asp:Button CommandName="Cancel" Text="Cancel" Size="6"
                   BackColor="#79C4DD" runat="server"/>
              <asp:Button CommandName="Update" Text="Update" Size="6"
                   BackColor="#79C4DD" runat="server"/>
            </EditItemTemplate>
            <FooterTemplate>
               <asp:Button CommandName="Insert" Text="Add" ID="cmdAdd" Size=12"
                   BackColor="#79C4DD" runat="server"/>
            </FooterTemplate>
          </asp:TemplateColumn>

          <asp:TemplateColumn HeaderText="">
            <ItemTemplate>
              <asp:Button id="btnDelete" CommandName="Delete" Text="Delete" Size="12"
                   BackColor="#79C4DD" runat="server"/>
            </ItemTemplate>
            <FooterTemplate>
               <asp:Button CommandName="CancelInsert" Text="CancelAdd" ID="cmdCancelAdd" Size=12"
                   BackColor="#79C4DD" runat="server"/>
            </FooterTemplate>
         </asp:TemplateColumn>

Here's my button logic:

  Sub ShowAdd(Sender As Object, E As DataGridCommandEventArgs)

    dgSelTuition.ShowFooter = True

    Dim item as DataGridItem
    For each Item in dgSelTuition.Items
      E.item.findcontrol("btnEdit").Visible = False
      E.item.findcontrol("btnDelete").Visible = False
    Next item

    dg_Load()

  End Sub

I get the error message:

BC30408: Method 'Public Sub ShowAdd(Sender As Object, E As System.Web.UI.WebControls.DataGridCommandEventArgs )' does not have the same signature as delegate 'Delegate Sub EventHandler(sender As Object, e As System.EventArgs)'.

Any advice?
 
Old June 5th, 2003, 09:52 AM
Authorized User
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 15
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to james_sellwood
Default

The error message you are getting I think is due to the fact that you are declaring the subprocedure using:

Code:
Sub ShowAdd(Sender As Object, E As DataGridCommandEventArgs)
The button that is calling this function is not part of the datagrid and so is unable to provide DataGridCommandEventArgs. You need to reword the declaration to:

Code:
Sub ShowAdd(Sender As Object, E As System.EventArgs)

--------------------
:) James Sellwood :)
--------------------




Similar Threads
Thread Thread Starter Forum Replies Last Post
paging enabled but hidden buttons DarkForce ASP.NET 2.0 Basics 1 July 27th, 2007 02:52 AM
How to modify hidden value? Edward King Javascript 2 January 21st, 2006 05:44 AM
calling one template in other template VijayKumar XSLT 3 September 15th, 2005 11:12 AM
Buttons in DataGrid Template Column divsalar ASP.NET 1.x and 2.0 Application Design 1 February 1st, 2005 03:37 PM
Hidden form value johnjohn Classic ASP Databases 2 November 10th, 2004 01:00 PM





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