asp:linkbutton - commandname behaviour

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"/>
 
J

John Saunders

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
 
J

John Blair

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top