sagar Jinturkar

sagar Jinturkar

  • NA
  • 214
  • 4.2k

Unable to cast error occured

Mar 22 2018 6:32 AM
Hello,
 
I've tried this below coding for delete link button on Gridview control for DataRowBound
 
butn  unfortunately i got an exception of unable to cast 
 
Please Suggest  
 
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow && e.Row.RowIndex != GridView1.EditIndex)
{
var deleteButton = (LinkButton)e.Row.Cells[0].Controls[2];
if (deleteButton.Text == "Delete")
{
deleteButton.OnClientClick = "return confirm('Do you really want to delete?');";
}
}
 

Answers (1)