Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Nathan Sokalski #1
DataList's EditCommand event not being raised
I am attempting to raise the EditCommand event of a DataList when a Button
in the ItemTemplate is clicked. Here is the HTML used for the ItemTemplate:
<ItemTemplate>
<asp:Label id=lblEvent1 runat="server" EnableViewState="False"
Width="175px" text='<%# DataBinder.Eval(Container,"DataItem.eventname")
%>'></asp:Label>
<asp:Label id=lblDescription1 runat="server" EnableViewState="False"
Width="500px" text='<%# DataBinder.Eval(Container,"DataItem.description")
%>'></asp:Label>
<asp:Label id=lblDate1 runat="server" EnableViewState="False" Width="100px"
text='<%# DataBinder.Eval(Container,"DataItem.eventdate","{0 :d}")
%>'></asp:Label>
<asp:Label id=lblDetails1 runat="server" EnableViewState="False"
Width="115px" text='<%# DataBinder.Eval(Container,"DataItem.details")
%>'></asp:Label>
<asp:Button id="btnEdit1" runat="server" Width="80px" Font-Bold="True"
CausesValidation="False" Text="Edit Event" CommandName="edit"></asp:Button>
</ItemTemplate>
Here is the event handler used to handle the EditCommand:
Private Sub datEditEvents_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataListCommandEventArgs ) Handles
datEditEvents.EditCommand
Label1.Text = "You clicked index " & CStr(e.Item.ItemIndex)
datEditEvents.EditItemIndex = e.Item.ItemIndex
Dim events As New DataSet
Dim myconnection As New
OracleConnection(System.Configuration.Configuratio nSettings.AppSettings("connectionString"))
Dim cmdselect As New OracleCommand("SELECT * FROM eventlist ORDER BY
eventdate", myconnection)
Dim eventsadapter As New OracleDataAdapter(cmdselect)
eventsadapter.SelectCommand = cmdselect
eventsadapter.Fill(events, "eventlist")
datEditEvents.DataSource = events
datEditEvents.DataBind()
End Sub
Notice that I did include the CommandName="edit" in my Button control and
the Handles clause in my event handler. When I click the button, nothing
happens. I tested this using a Label which you see as the first line in my
event handler. What am I forgetting? Is the CommandName attribute
case-sensitive? Am I using the wrong value? Any help would be appreciated.
Thanks.
--
Nathan Sokalski
[email]njsokalski@hotmail.com[/email]
[url]http://www.nathansokalski.com/[/url]
Nathan Sokalski Guest
-
DataList's EditCommand not being raised
I am attempting to raise the EditCommand event of a DataList when a Button in the ItemTemplate is clicked. Here is the HTML used for the... -
ListControl: SelectedIndexChanged event raised without implementing IPostBackDataHandler?
Hi, I'm designing a control that inherits ListControl I was surprised to see that SelectedIndexChanged is part of ListControl. So why doesn't it... -
ItemDataBound Event - How to access the previous record when this event is raised in DataGrid?
ItemDataBound Event - How to access the previous record when this event is raised in DataGrid? During "ItemDataBound Event", I would like... -
EditCommand event
Does anyone know how DataGrid knows which index of an Edit button/link caused the postback so as to pass it along as an argument to EditCommand... -
EditCommand event in Datagrid question
Hi, I have a few questions about the EditCommand event in the DataGrig in asp.net. When I get to the EditCommand event in my code I need to...



Reply With Quote

