Results 1 to 4 of 4

Thread: [Resolved] OnEditCommand Not Firing in DataList

Threaded View

  1. #1

    Thread Starter
    Fanatic Member Redth's Avatar
    Join Date
    May 2001
    Location
    Ontario, Canada
    Posts
    551

    [Resolved] OnEditCommand Not Firing in DataList

    Hello,

    I had a page that I coded in Dreamweaver, before i was convinced to start using VS.NET IDE... Well, I had a DataList that had a button in the itemtemplate. every time the button was clicked, i had the EditCommand Event fire for the Datalist, and from there did what i needed to do..

    Now i'm converting this page to using codebehind, and i'm using VisualStudio.NET to code in. I can't seem to get the EditCommand Event to fire for the life of me.

    Here is my HTML for the DataList:

    VB Code:
    1. <table width="500" align="center" border="0" cellpadding="0" cellspacing="0">
    2.     <asp:DataList HeaderStyle-HorizontalAlign="center" id="dlZipCodes" runat="server" Width="500" Height="80">
    3.         <HeaderTemplate>
    4.             <tr>
    5.                 <td><strong><font size="2" face="Verdana">Expires:</font></strong><font size="2" face="Verdana">&nbsp;</font></td>
    6.                 <td><font size="2" face="Verdana"><strong>Visible:</strong></font></td>
    7.                 <td><font size="2" face="Verdana"><strong>Zip Code:</strong></font></td>
    8.                 <td>&nbsp;</td>
    9.             </tr>
    10.         </HeaderTemplate>
    11.         <ItemTemplate>
    12.             <tr>
    13.                 <td><%# Convert.ToDateTime(Container.DataItem("Expires")).ToShortDateString %></td>
    14.                 <td>
    15.                     <asp:CheckBox ID="chkZIP_Visible" Runat="server" Text="" Checked='<%# Container.DataItem("Visible") %>' />
    16.                 </td>
    17.                 <td>
    18.                     <asp:DropDownList Runat="server" ID="lstZipCodes"></asp:DropDownList>
    19.                 </td>
    20.                 <td>
    21.                     <asp:Button CommandName="edit" Runat="server" Text="Update" />
    22.                     <asp:Label Runat="server" ID="lblZIP_ID" Visible="True" Text='<%# Container.DataItem("ID") %>' />
    23.                     <asp:Label Runat="server" ID="lblZIP_Zip" Visible="True" text='<%# Container.DataItem("ZipCode") %>' />
    24.                 </td>
    25.             </tr>
    26.         </ItemTemplate>
    27.     </asp:DataList>
    28. </table>



    Here's the Event Code in my CodeBehind:
    VB Code:
    1. Private Sub dlZipCodes_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlZipCodes.EditCommand
    2.  
    3.           'My Code Here
    4.            Dim objFile As System.IO.TextWriter
    5.            objFile = IO.File.CreateText("F:\Out.txt")
    6.            objFile.WriteLine("UPDATE ZipCodes SET ZipCode = '" & strZip & "', Visible = " & intVisible & " WHERE ID = " & intID)
    7.            objFile.Close()
    8.  
    9. End Sub

    I can't figure out what is going wrong.. the event never fires (i've stuck in some code in the sub that writes to a textfile, but the text file remains empty to no avail :/..

    Anyways, i'm sure there's something small that i'm missing, i just can't figure out what... thanks for the help guys!
    Last edited by Redth; Jan 4th, 2003 at 11:14 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width