asp:linkbutton - commandname behaviour

  • Thread starter Thread starter John Blair
  • Start date Start date
J

John Blair

Hi,

The OnSelectedIndexChanged event only seems to fire if commandname = "select" if i change it to anything else if does not fire.
Can anyone explain why this is the case given this name is meant to be capable of being set to anything?

Thank you.


<ASP:DataList id="MyDataList" OnSelectedIndexChanged="MyDataList_Select" DataKeyField="title_id" runat="server">

<ItemTemplate>

<table cellpadding=10 style="font: 10pt verdana">
<tr>
<td valign="top">
<img align="top" width="25" border=1 src='<%# DataBinder.Eval(Container.DataItem, "title_id", "/quickstart/aspplus/images/title-{0}.gif") %>' runat="server" ID="Img1"/>
</td>
<td valign="top">
<b>Title: </b>
<asp:linkbutton Text='<%# DataBinder.Eval(Container.DataItem, "title") %>' CommandName="Select" style="color:darkred" runat="server" ID="Linkbutton1"/>
 
Hi,

The OnSelectedIndexChanged event only seems to fire if commandname = "select" if i change it to anything else if does not fire.
Can anyone explain why this is the case given this name is meant to be capable of being set to anything?

It is capable of being set to anything, but only "select" means that the SelectedIndexChanged event should be fired. In the same way, "update" will fire the UpdateCommand event and "cancel" will fire the CancelCommand event.

If you want to use a command name other than the standard ones, you can pick up the click within the ItemCommand event handler.

John Saunders
 
Thanks a lot!
"John Saunders" <johnwsaundersiii at hotmail.com> wrote in message Hi,

The OnSelectedIndexChanged event only seems to fire if commandname = "select" if i change it to anything else if does not fire.
Can anyone explain why this is the case given this name is meant to be capable of being set to anything?

It is capable of being set to anything, but only "select" means that the SelectedIndexChanged event should be fired. In the same way, "update" will fire the UpdateCommand event and "cancel" will fire the CancelCommand event.

If you want to use a command name other than the standard ones, you can pick up the click within the ItemCommand event handler.

John Saunders
 
Back
Top