This is a migrated thread and some comments may be shown as answers.

Delete row in grid and prompt alert message

5 Answers 477 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joey
Top achievements
Rank 1
Joey asked on 12 Dec 2008, 02:44 AM
Hi,

The problem that i am facing is, when i delete one row in grid, i need to do some checking then prompt it alert message in screen.
As i know, when we do deletion in grid, it only can call to code behind 

protected

void radImp_DeleteCommand(object source, Telerik.WebControls.GridCommandEventArgs e)

 

 

{

 

 

    string sOBFPkID = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Id"].ToString();

    Utility.

BaseDelete.DeleteApplFacCollatREImprovement(sOBFPkID);

 

 

 

}
before i delete that record i need to do some checking first,if that record fulfill to my checking then i need to prompt a alert msg in screen.
How can i make it??
Thanks


5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 12 Dec 2008, 07:35 AM
Hi Joey,

You can prompt just before submitting the form using ConfirmText of GridButtonColumn however in your case you will need to perform  double post-back to achieve your goal. The first post-back will be to perform desired checking and display desired alert using RadAjaxManager.ResponseScripts.Add("alert('Your text!');"). and the second post-back will be the actual record delete.

Regards,
Vlad
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Per
Top achievements
Rank 1
answered on 30 Mar 2009, 08:46 AM
Hi!

I'm having the exact problem my self.
Could you please provide some example code?

Regards
Per
0
Sebastian
Telerik team
answered on 30 Mar 2009, 01:58 PM
Hello guys,

How to display a confirmation dialog on delete operation you can see from the following article in the RadGrid for ASP.NET AJAX documentation:

http://www.telerik.com/help/aspnet-ajax/grid-adding-delete-prompt.html

Feel free to modify/expand the solution to conform to your custom logic.

Best regards,
Sebastian
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Ajay Gosain
Top achievements
Rank 1
answered on 13 Feb 2010, 03:43 PM

Hi I also need the same solution. Also please note that right now we are using Trial version.

The article you have shown is binding grid at design time.

I am populating grid during runtime, so I do not have any item in radgrid at design time.

Even I cound not find "DeleteColumn" using the code.

Here is my code behind for my radgrid.



 

 

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" Height="200px" Width="300px">

 

 

 

 

 

<tr>

 

 

 

 

 

<td>

 

 

 

 

 

<telerik:RadGrid ID="radUserGrid" AllowFilteringByColumn="True"

 

 

AllowSorting="True" PageSize="5"

 

 

 

 

 

ShowFooter="True" AllowPaging="True" runat="server" GridLines="None"

 

 

AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True">

 

 

 

 

 

<ClientSettings>

 

 

 

 

 

<Selecting AllowRowSelect="True" />

 

 

 

 

 

</ClientSettings>

 

 

 

 

 

 

</telerik:RadGrid>

 

 

 

 

 

</td>

 

 

 

 

 

</tr>

 

 

</telerik:RadAjaxPanel>

 



Your prompt response will be highly appreciated.
0
Princy
Top achievements
Rank 2
answered on 25 Feb 2011, 08:25 AM
Hello Ajay,

You can try the following code snippet to display confirmation dialog for AutoGeneratedDeleteColumn.

C#:
protected void radUserGrid_ItemDataBound(object sender, GridItemEventArgs e)
  {
      if (e.Item is GridDataItem)
      {
          GridDataItem dataItem = e.Item as GridDataItem;
          LinkButton button = dataItem.FindControl("AutoGeneratedDeleteButton") as LinkButton;
          button.Attributes["onclick"] = "return confirm('Are you sure you want to delete ?')";
      }
  }

Thanks,
Princy.
Tags
Grid
Asked by
Joey
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Per
Top achievements
Rank 1
Sebastian
Telerik team
Ajay Gosain
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or