D
Dave
I have a gridview that has Edit, Delete, and Select enabled. I'm
trying to run the below C# to prompt when deleting.
protected void DetailGridView_RowCreated(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton l = ((LinkButton)e.Row.Cells[0].Controls[1]);
l.Attributes.Add("onclick", "javascript:return " +
"confirm('Are you sure you want to delete the " +
DataBinder.Eval(e.Row.DataItem, "SOCDetail") + " SOC
Detail Entry?')");
}
}
When the control renders I'm getting the below Error:
Unable to cast object of type 'System.Web.UI.LiteralControl' to type
'System.Web.UI.WebControls.LinkButton'.
What am I doing wrong?
Thanks
trying to run the below C# to prompt when deleting.
protected void DetailGridView_RowCreated(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton l = ((LinkButton)e.Row.Cells[0].Controls[1]);
l.Attributes.Add("onclick", "javascript:return " +
"confirm('Are you sure you want to delete the " +
DataBinder.Eval(e.Row.DataItem, "SOCDetail") + " SOC
Detail Entry?')");
}
}
When the control renders I'm getting the below Error:
Unable to cast object of type 'System.Web.UI.LiteralControl' to type
'System.Web.UI.WebControls.LinkButton'.
What am I doing wrong?
Thanks