View Single Post
  #1 (permalink)  
Old June 4th, 2003, 08:38 AM
mlwallin mlwallin is offline
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?