Posted 23 Sep 2013 Link to this post
<
telerik:GridButtonColumn
UniqueName
=
"GridButtonColumn"
ButtonType
"PushButton"
>
</
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
GridDataItem item = (GridDataItem)e.Item;
Button btn = (Button)item[
].Controls[0];
btn.Attributes.Add(
"OnClick"
,
"OnClicks("
+ btn.ClientID +
");return false;"
);
}
<script type=
"text/javascript"
function
OnClicks(id) {
//Your Code
</script>
Posted 27 Feb 2019 in reply to Princy Link to this post
That doesn't work for me. I get: Unable to cast object of type 'GridButtonColumnImageButton' to type 'System.Web.UI.WebControls.Button'.
Posted 04 Mar 2019 Link to this post
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.
Posted 04 Mar 2019 in reply to Marin Bratanov Link to this post