p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   ASP.NET 1.0 and 1.1 Basics (http://p2p.wrox.com/forumdisplay.php?f=60)
-   -   Hidden template buttons (http://p2p.wrox.com/showthread.php?t=99)

mlwallin June 4th, 2003 08:38 AM

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?

james_sellwood June 5th, 2003 09:52 AM

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 :)
--------------------


All times are GMT -4. The time now is 04:41 PM.

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