|
-
Jan 3rd, 2003, 01:56 AM
#1
Thread Starter
Fanatic Member
[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:
<table width="500" align="center" border="0" cellpadding="0" cellspacing="0">
<asp:DataList HeaderStyle-HorizontalAlign="center" id="dlZipCodes" runat="server" Width="500" Height="80">
<HeaderTemplate>
<tr>
<td><strong><font size="2" face="Verdana">Expires:</font></strong><font size="2" face="Verdana"> </font></td>
<td><font size="2" face="Verdana"><strong>Visible:</strong></font></td>
<td><font size="2" face="Verdana"><strong>Zip Code:</strong></font></td>
<td> </td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td><%# Convert.ToDateTime(Container.DataItem("Expires")).ToShortDateString %></td>
<td>
<asp:CheckBox ID="chkZIP_Visible" Runat="server" Text="" Checked='<%# Container.DataItem("Visible") %>' />
</td>
<td>
<asp:DropDownList Runat="server" ID="lstZipCodes"></asp:DropDownList>
</td>
<td>
<asp:Button CommandName="edit" Runat="server" Text="Update" />
<asp:Label Runat="server" ID="lblZIP_ID" Visible="True" Text='<%# Container.DataItem("ID") %>' />
<asp:Label Runat="server" ID="lblZIP_Zip" Visible="True" text='<%# Container.DataItem("ZipCode") %>' />
</td>
</tr>
</ItemTemplate>
</asp:DataList>
</table>
Here's the Event Code in my CodeBehind:
VB Code:
Private Sub dlZipCodes_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlZipCodes.EditCommand
'My Code Here
Dim objFile As System.IO.TextWriter
objFile = IO.File.CreateText("F:\Out.txt")
objFile.WriteLine("UPDATE ZipCodes SET ZipCode = '" & strZip & "', Visible = " & intVisible & " WHERE ID = " & intID)
objFile.Close()
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|