FormView not displaying the correct templates

Discussion in 'ASP .Net' started by Nathan Sokalski, Aug 26, 2007.

  1. I have a FormView control with the following templates:

    EmptyDataTemplate
    ItemTemplate
    EditItemTemplate
    InsertItemTemplate

    I am not using Paging, because the FormView is simply being used to display
    the fields from a database. The user selects the record using a ListBox (I
    am not using Paging because I want to allow the user to select the record
    through scrolling). I have managed to get the FormView to display the data
    for the selected record when the user selects a different item in the
    ListBox, but the buttons that I have in the templates do not seem to be
    working.

    <asp:Button ID="btnAdd" runat="server" Text="Add New Record"
    CommandName="new"/>
    <asp:Button ID="btnDelete" runat="server" Text="Delete Selected Item"
    CommandName="delete"/>
    <asp:Button ID="btnEdit" runat="server" Text="Edit Record"
    CommandName="edit"/>

    The buttons do not even seem to be triggering the events, such as
    ItemInserting. When I tried using LinkButtons instead with the same
    CommandName attributes, it triggered the ItemCommand and ModeChanging events
    (There is currently no code in these events). Why won't the FormView let me
    go to the EditItemTemplate and InsertItemTemplate? Is there something I need
    to do in the ItemCommand or ModeChanging events? Also, although not my top
    priority right now, why is the LinkButton working but not the Button, they
    both have a CommandName property and inherit and implement the same classes
    and interfaces? If someone can please help me here, I would appreciate it.
    Thanks.
     
    Nathan Sokalski, Aug 26, 2007
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.