ListView does not edit

Discussion in 'ASP .Net' started by David C, Jul 26, 2009.

  1. David C

    David C Guest

    I have a ListView bound to an SQL table but it never goes into Edit mode nor
    does the Insert button add any records. I have looked at it for hours and
    cannot see anything. Below is most of the page. Can someone please help?
    Thanks.

    David

    <form id="form1" runat="server">
    <div>
    <asp:TextBox ID="TextBox1" runat="server" Width="800"></asp:TextBox>
    <asp:TextBox ID="txtRecordID" runat="server"
    Text="22631"></asp:TextBox>

    <asp:ListView ID="lvRepairOrderNotes" runat="server"
    DataKeyNames="NotesID"
    DataSourceID="SqlRepairOrderNotes" Visible="True">
    <ItemTemplate>
    <tr style="background-color:#DCDCDC;color: #000000;">
    <td><asp:Label ID="LblActivityDate" runat="server"
    Text='<%# Eval("ActivityDate", "{0:M/d/yyyy h:mm tt}") %>' />
    </td>
    <td><asp:Label ID="LblActivityType" runat="server"
    Text='<%# Eval("ActivityType") %>' />
    </td>
    <td><asp:Label ID="LblActivityNotes" runat="server"
    Text='<%# Eval("ActivityNotes") %>' />
    </td>
    <td><asp:Label ID="LblEnteredBy" runat="server"
    Text='<%# Eval("EnteredBy") %>' />
    </td>
    <td><asp:Label ID="LblFollowupDate" runat="server"
    Text='<%# Eval("FollowupDate", "{0:d}") %>' />
    </td>
    <td><asp:Label ID="LblNotesID" runat="server" Text='<%#
    Eval("NotesID") %>' CssClass="Hide" />
    </td>
    <td><asp:Label ID="LblRecordID" runat="server" Text='<%#
    Eval("RecordID") %>' CssClass="Hide" />
    </td>
    <td><asp:LinkButton ID="LBtnEdit" runat="server"
    CommandName="Edit" Text="Edit" />
    </td>
    </tr>
    </ItemTemplate>
    <AlternatingItemTemplate>
    <tr style="background-color:#FFF8DC;">
    <td><asp:Label ID="LblActivityDate" runat="server"
    Text='<%# Eval("ActivityDate", "{0:M/d/yyyy h:mm tt}") %>' />
    </td>
    <td><asp:Label ID="LblActivityType" runat="server"
    Text='<%# Eval("ActivityType") %>' />
    </td>
    <td><asp:Label ID="LblActivityNotes" runat="server"
    Text='<%# Eval("ActivityNotes") %>' />
    </td>
    <td><asp:Label ID="LblEnteredBy" runat="server"
    Text='<%# Eval("EnteredBy") %>' />
    </td>
    <td><asp:Label ID="LblFollowupDate" runat="server"
    Text='<%# Eval("FollowupDate", "{0:d}") %>' />
    </td>
    <td><asp:Label ID="LblNotesID" runat="server" Text='<%#
    Eval("NotesID") %>' CssClass="Hide" />
    </td>
    <td><asp:Label ID="LblRecordID" runat="server" Text='<%#
    Eval("RecordID") %>' CssClass="Hide" />
    </td>
    <td><asp:LinkButton ID="LBtnEditAlt" runat="server"
    CommandName="Edit" Text="Edit" />
    </td>
    </tr>
    </AlternatingItemTemplate>
    <EmptyDataTemplate>
    <table runat="server"
    style="background-color: #FFFFFF;border-collapse:
    collapse;border-color: #999999;
    border-style:none;border-width:1px;">
    <tr>
    <td>No Repair Notes found.</td>
    </tr>
    </table>
    </EmptyDataTemplate>
    <InsertItemTemplate>
    <tr style="">
    <td><asp:TextBox ID="txtActivityDate" runat="server"
    Text='<%# Bind("ActivityDate", "{0:M/d/yyyy h:mm tt}") %>' />
    </td>
    <td><asp:TextBox ID="txtActivityType" runat="server"
    Text='<%# Bind("ActivityType") %>' />
    </td>
    <td><asp:TextBox ID="txtActivityNotes" runat="server"
    Text='<%# Bind("ActivityNotes") %>' />
    </td>
    <td><asp:TextBox ID="txtEnteredBy" runat="server"
    Text='<%# Bind("EnteredBy") %>' />
    </td>
    <td><asp:TextBox ID="txtFollowupDate" runat="server"
    Text='<%# Bind("FollowupDate") %>' />
    </td>
    <td>&nbsp;</td>
    <td><asp:TextBox ID="txtRecordID" runat="server"
    Text='<%# Bind("RecordID") %>' CssClass="Hide" />
    </td>
    <td><asp:Button ID="InsertButton" runat="server"
    CommandName="Insert" Text="Insert" />
    <asp:Button ID="CancelButton" runat="server"
    CommandName="Cancel" Text="Clear" /></td>
    </tr>
    </InsertItemTemplate>
    <LayoutTemplate>
    <table runat="server">
    <tr runat="server">
    <td runat="server">
    <table ID="itemPlaceholderContainer"
    runat="server" border="1"
    style="background-color:
    #FFFFFF;border-collapse: collapse;border-color:
    #999999;border-style:none;border-width:1px;font-family: Verdana, Arial,
    Helvetica, sans-serif;">
    <tr runat="server"
    style="background-color:#DCDCDC;color: #000000;">
    <th runat="server">
    ActivityDate</th>
    <th runat="server">
    ActivityType</th>
    <th runat="server">
    ActivityNotes</th>
    <th runat="server">
    EnteredBy</th>
    <th runat="server">
    FollowupDate</th>
    <th runat="server">
    </th>
    <th runat="server">
    </th>
    <th runat="server">
    </th>
    </tr>
    <tr ID="itemPlaceholder" runat="server">
    </tr>
    </table>
    </td>
    </tr>
    <tr runat="server">
    <td runat="server"
    style="text-align: center;background-color:
    #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;">
    </td>
    </tr>
    </table>
    </LayoutTemplate>
    <EditItemTemplate>
    <tr style="background-color:#008A8C;color: #FFFFFF;">
    <td><asp:TextBox ID="txtActivityDate" runat="server"
    Text='<%# Bind("ActivityDate") %>' />
    </td>
    <td><asp:TextBox ID="txtActivityType" runat="server"
    Text='<%# Bind("ActivityType") %>' />
    </td>
    <td><asp:TextBox ID="txtActivityNotes" runat="server"
    Text='<%# Bind("ActivityNotes") %>' />
    </td>
    <td><asp:TextBox ID="txtEnteredBy" runat="server"
    Text='<%# Bind("EnteredBy") %>' />
    </td>
    <td><asp:TextBox ID="txtFollowupDate" runat="server"
    Text='<%# Bind("FollowupDate") %>' />
    </td>
    <td><asp:Label ID="LblNotesID" runat="server" Text='<%#
    Eval("NotesID") %>' CssClass="Hide" />
    </td>
    <td><asp:TextBox ID="txtRecordID" runat="server"
    Text='<%# Bind("RecordID") %>' CssClass="Hide" />
    </td>
    <td><asp:LinkButton ID="LBtnUpdateNote" runat="server"
    CommandName="Update" Text="Update" />
    <asp:LinkButton ID="LBtnCancelNote" runat="server"
    CommandName="Cancel" Text="Cancel" />
    </td>
    </tr>
    </EditItemTemplate>
    <SelectedItemTemplate>
    <tr style="background-color:#008A8C;font-weight: bold;color:
    #FFFFFF;">
    <td><asp:Label ID="LblActivityDate" runat="server"
    Text='<%# Eval("ActivityDate") %>' />
    </td>
    <td><asp:Label ID="LblActivityType" runat="server"
    Text='<%# Eval("ActivityType") %>' />
    </td>
    <td><asp:Label ID="LblActivityNotes" runat="server"
    Text='<%# Eval("ActivityNotes") %>' />
    </td>
    <td><asp:Label ID="LblEnteredBy" runat="server"
    Text='<%# Eval("EnteredBy") %>' />
    </td>
    <td><asp:Label ID="LblFollowupDate" runat="server"
    Text='<%# Eval("FollowupDate", "{0:d}") %>' />
    </td>
    <td><asp:Label ID="LblNotesID" runat="server" Text='<%#
    Eval("NotesID") %>' />
    </td>
    <td><asp:Label ID="LblRecordID" runat="server" Text='<%#
    Eval("RecordID") %>' />
    </td>
    <td><asp:LinkButton ID="LBtnEdit" runat="server"
    CommandName="Edit" Text="Edit" />
    </td>
    </tr>
    </SelectedItemTemplate>

    </asp:ListView>

    <asp:SqlDataSource ID="SqlRepairOrderNotes" runat="server"
    ConnectionString="<%$ ConnectionStrings:MgmtConnectionString %>"
    ProviderName="<%$
    ConnectionStrings:MgmtConnectionString.ProviderName %>"
    DeleteCommand="DELETE FROM [RepairOrderNotes] WHERE [NotesID] =
    @NotesID"
    InsertCommand="INSERT INTO [RepairOrderNotes] ([RecordID],
    [ActivityDate], [ActivityType], [ActivityNotes], [EnteredBy],
    [FollowupDate]) VALUES (@txtRecordID, @ActivityDate, @ActivityType,
    @ActivityNotes, @EnteredBy, @FollowupDate)"
    SelectCommand="SELECT [NotesID], [RecordID], [ActivityDate],
    [ActivityType], [ActivityNotes], [EnteredBy], [FollowupDate] FROM
    [RepairOrderNotes] WHERE ([RecordID]=@txtRecordID) ORDER BY [ActivityDate]
    DESC"
    UpdateCommand="UPDATE [RepairOrderNotes] SET [ActivityDate] =
    @ActivityDate, [ActivityType] = @ActivityType, [ActivityNotes] =
    @ActivityNotes, [EnteredBy] = @EnteredBy, [FollowupDate] = @FollowupDate
    WHERE [NotesID] = @NotesID">
    <SelectParameters>
    <asp:ControlParameter ControlID="txtRecordID"
    Name="txtRecordID" PropertyName="Text" Type="Int32" />
    </SelectParameters>
    <DeleteParameters>
    <asp:parameter Name="NotesID" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
    <asp:ControlParameter ControlID="txtRecordID"
    Name="txtRecordID" PropertyName="Text" Type="Int32" />
    <asp:parameter Name="ActivityDate" Type="DateTime" />
    <asp:parameter Name="ActivityType" Type="String" />
    <asp:parameter Name="ActivityNotes" Type="String" />
    <asp:parameter Name="EnteredBy" Type="String" />
    <asp:parameter Name="FollowupDate" Type="DateTime" />
    </InsertParameters>
    <UpdateParameters>
    <asp:parameter Name="ActivityDate" Type="DateTime" />
    <asp:parameter Name="ActivityType" Type="String" />
    <asp:parameter Name="ActivityNotes" Type="String" />
    <asp:parameter Name="EnteredBy" />
    <asp:parameter Name="FollowupDate" Type="DateTime" />
    <asp:parameter Name="NotesID" Type="Int32" />
    </UpdateParameters>
    </asp:SqlDataSource>
    </div>

    </form>
     
    David C, Jul 26, 2009
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. San Diego Guy
    Replies:
    0
    Views:
    571
    San Diego Guy
    Aug 7, 2003
  2. Schultz
    Replies:
    3
    Views:
    581
    =?Utf-8?B?QmlsbCBCb3Jn?=
    Feb 14, 2005
  3. shapper

    ListView. Cancel. It does not!

    shapper, Mar 6, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    390
    shapper
    Mar 6, 2008
  4. Ryan Liu
    Replies:
    1
    Views:
    2,287
    Alexey Smirnov
    Jan 21, 2009
  5. .
    Replies:
    0
    Views:
    769
Loading...

Share This Page