Chris,
The only controls that will have an event are PAGE level controls.
Once you place a button inside a Datalist, it is now a CHILD of the datalist
and will need to use the Datalist's events instead.
For the button, you will need to assign, through databinding, these
attributes
CommandArguement
CommandName
BUTTON EXAMPLE
<asp:button id="Button1" runat="server" text="Push me" commandarguement='<%#
Container.DataItem("primaryKey") %>' commandname="Action" />
This sets the CommandArguement equal to the primary key of the record.
Now, for the event that will occur when button is pushed - This is the
Datalist's ItemCommand Event
Private Sub DataList1_ItemCommand(source as object, e as datalisteventargs)
Handles Datalist1.ItemCommand
'Assign a variable to hold CommandArgument
Dim primaryKey as Integer
primaryKey = CInt(e.CommandArguement)
'use this primaryKey variable in logic below
'Also, if there are more than one button (edit, delete, copy, etc)
'You put that "Action" in the CommandName attribute and use like so...
If e.CommandName = "Delete" Then
OleDbCommand1.CommandText = "DELETE DISTINCT FROM table WHERE
[primaryKey]="& primaryKey &";"
End If
End sub
Hope this helps,
Severin
"Chris Fink" <ch***@chrisfink.com> wrote in message
news:e%***************@TK2MSFTNGP11.phx.gbl...
Hello,
I have a datalist that contains an asp button. I have the need to pass a
value that is bound to my datalist along the button when the on_click
event is fired. My datalist creates a button for each row in my datasource, so
each button needs to pass a unique value. My questions are:
1. How do I pass the value with the button without making it visible on
the button or form.
2. Is there a way to grab this value in the button's event parameters, the
sender as system.object or the e as system.eventArgs
This button was previosly an anchor tag that passed the value through the
HREF querystring, but I did not like how it lost all the viewstate when I
redirected back.
Any help is appreciated,
Thanks