Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cannot get Delete Verification to work
Message
General information
Forum:
ASP.NET
Category:
WebForms
Miscellaneous
Thread ID:
01173548
Message ID:
01173603
Views:
9
Richard,

Firstly, I am assuming you have set the DataKeyNames property on the gridview and the data source DeleteCommand and DeleteParameters correctly?

I tend to put this code in the RowDataBound event of the grid, this gives me the opportunity to personalise the message using something along the following lines.
protected void GridViewTest_RowDataBound(object sender, GridViewRowEventArgs e)
{
   if (e.Row.RowType == DataControlRowType.DataRow)
      {
         if (e.Row.RowState == DataControlRowState.Edit || 
             e.Row.RowState == (DataControlRowState.Alternate | DataControlRowState.Edit))
            {
               // ...
            }
            else
            {
               LinkButton DeleteButton = (LinkButton)e.Row.Cells[1].Controls[0];
                DataRow MyDataRow = (DataRow)((DataRowView)e.Row.DataItem).Row;

                if (DeleteButton != null && MyDataRow != null)
                {
                    DeleteButton.OnClientClick = "return confirm('" +
                        string.Format((string)base.GetLocalResourceObject("String.RecordDeletePrompt"),
                        ((string)MyDataRow["Name"]).Replace("'", @"\'")) + "');";
                }
            }
        }
    }
}
The (string)base.GetLocalResourceObject("String.RecordDeletePrompt") is loading a string from an embedded resource.
You are about to delete {0} from the table
Regards
Neil
Previous
Reply
Map
View

Click here to load this message in the networking platform