4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 24 Sep 2013, 03:56 AM
Hi ,
Please try the following code snippet to raise the Client Event on GridButtonColumn.
ASPX:
C#:
JS:
Thanks,
Princy
Please try the following code snippet to raise the Client Event on GridButtonColumn.
ASPX:
<
telerik:GridButtonColumn
UniqueName
=
"GridButtonColumn"
ButtonType
=
"PushButton"
>
</
telerik:GridButtonColumn
>
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
Button btn = (Button)item[
"GridButtonColumn"
].Controls[0];
btn.Attributes.Add(
"OnClick"
,
"OnClicks("
+ btn.ClientID +
");return false;"
);
}
}
JS:
<script type=
"text/javascript"
>
function
OnClicks(id) {
//Your Code
}
</script>
Thanks,
Princy
0
Travis Richardson
Top achievements
Rank 1
answered on 27 Feb 2019, 05:34 PM
That doesn't work for me. I get: Unable to cast object of type 'GridButtonColumnImageButton' to type 'System.Web.UI.WebControls.Button'.
0
Hello Travis,
Regards,
Marin Bratanov
Progress Telerik
The ButtonType property of the column determines what type of control is used. If you don't know what that will be, you should add some defensive type checks.
Also, if you want full control over the code, you should use a template column - you can add your own button there with the desired logic, and command name, and appearance.
Regards,
Marin Bratanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Travis Richardson
Top achievements
Rank 1
answered on 04 Mar 2019, 02:40 PM
Ah yes, 'Button Type'. Well that seems obvious now! Thanks.