I am trying to inherit GridBoundColumn.
where i override preparecell method.
I am putting an ImageButton in GridDataItem.
now i need to fire owner grid ItemCommand event on this ImageButton's Click event.
How can i do that?
check out this code.
[ToolboxData("<{0}:ActiveDeactiveColumn runat=server></{0}:ActiveDeactiveColumn>")]
public class ActiveDeactiveColumn : GridBoundColumn
{
public override void PrepareCell(TableCell cell, GridItem item)
{
if (item is GridHeaderItem)
{
Literal lt = new Literal();
lt.Text = this.HeaderText;
cell.Controls.Add(lt);
}
if (item is GridDataItem)
{
ImageButton imgBtn = new ImageButton();
bool value = (Boolean)DataBinder.Eval(item.DataItem, this.DataField);
String url = value ? "OSS.Resources.tick.gif" : "OSS.Resources.cross.gif";
imgBtn.ImageUrl = this.Owner.OwnerGrid.Page.ClientScript.GetWebResourceUrl(this.GetType(), url);
imgBtn.OnClientClick = "return confirm('Are you sure want to " + (value ? "deactivate" : "activate") + " this record?')";
imgBtn.CommandName = value ? "deactivate" : "activate";
//What should be written Here?
//imgBtn.Click += ""???
// how can i bind this.owner.ownerGrid.ItemCommand (RadGrid.ItemCommand) event to this ImageButton event?
cell.Controls.Add(imgBtn);
}
}
}