Hello,
I am using the (latest?) version 2008.3.1125.35 of the Telerik RadControls for ASP.NET Ajax.
In this small example below, I can not make the pushbutton fire the ItemCommand event. With the ImageButton, everything is fine.
It is not a blocking thing but I would rather use a button because I have a css class ready for it.
Can someone please tell me if it is a bug or am I doing something wrong?
Thank you,
Default.aspx:
Default.aspx.cs:
I am using the (latest?) version 2008.3.1125.35 of the Telerik RadControls for ASP.NET Ajax.
In this small example below, I can not make the pushbutton fire the ItemCommand event. With the ImageButton, everything is fine.
It is not a blocking thing but I would rather use a button because I have a css class ready for it.
Can someone please tell me if it is a bug or am I doing something wrong?
Thank you,
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication4._Default" %> |
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml" > |
<head runat="server"> |
<title></title> |
</head> |
<body> |
<form id="form1" runat="server"> |
<asp:ScriptManager ID="ScriptManager1" runat="server"> |
</asp:ScriptManager> |
<div> |
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" |
AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" |
GridLines="None" onitemcommand="RadGrid1_ItemCommand" |
onitemdatabound="RadGrid1_ItemDataBound"> |
<HeaderContextMenu> |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
</HeaderContextMenu> |
<MasterTableView datakeynames="CategoryID" datasourceid="SqlDataSource1"> |
<RowIndicatorColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</RowIndicatorColumn> |
<ExpandCollapseColumn> |
<HeaderStyle Width="20px"></HeaderStyle> |
</ExpandCollapseColumn> |
<Columns> |
<telerik:GridBoundColumn DataField="CategoryID" DataType="System.Int32" |
HeaderText="CategoryID" ReadOnly="True" SortExpression="CategoryID" |
UniqueName="CategoryID"> |
</telerik:GridBoundColumn> |
<telerik:GridBoundColumn DataField="CategoryName" HeaderText="CategoryName" |
SortExpression="CategoryName" UniqueName="CategoryName"> |
</telerik:GridBoundColumn> |
<telerik:GridButtonColumn CommandName="DeleteP" UniqueName="DeleteP" Text="Delete" ButtonType="PushButton"> |
</telerik:GridButtonColumn> |
<telerik:GridButtonColumn CommandName="DeleteL" UniqueName="DeleteL" Text="Delete" ButtonType="LinkButton"> |
</telerik:GridButtonColumn> |
</Columns> |
</MasterTableView> |
<FilterMenu> |
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> |
</FilterMenu> |
</telerik:RadGrid> |
<asp:SqlDataSource ID="SqlDataSource1" runat="server" |
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" |
SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]"> |
</asp:SqlDataSource> |
</div> |
<telerik:RadAjaxManager runat="server"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="RadGrid1"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="RadGrid1" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManager> |
</form> |
</body> |
</html> |
Default.aspx.cs:
using System.Web.UI; |
using System.Web.UI.WebControls; |
using Telerik.Web.UI; |
namespace WebApplication4 |
{ |
public partial class _Default : Page |
{ |
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
string cmdName = e.CommandName; |
string cmdArg = e.CommandArgument.ToString(); |
} |
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
if (e.Item is GridDataItem) |
{ |
var dataBoundItem = e.Item as GridDataItem; |
var btnP = dataBoundItem["DeleteP"].Controls[0] as Button; |
btnP.OnClientClick = "return confirm('ok " + dataBoundItem["CategoryName"].Text + "?');"; |
btnP.CommandArgument = dataBoundItem["CategoryID"].Text; |
var btnL = dataBoundItem["DeleteL"].Controls[0] as LinkButton; |
btnL.OnClientClick = btnP.OnClientClick; |
btnL.CommandArgument = btnP.CommandArgument; |
} |
} |
} |
} |