I need to add the number of records selected for deletion to the confirm dialogue box.
I have a RadGrid with a programmatically added GridClientSelectColumn (for the checkboxes for each row in the grid) and GridCommandItem that is a linkbutton with text = "Delete Selected". What I like to be able to do is have a confirmation dialog box appear with the number of records the client as has selected to delete.
protected
void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if
(e.Item is GridCommandItem)
{
LinkButton Delete = e.Item.FindControl("btnDeleteSelected") as LinkButton;
string js = null;
js =
"javascript:return confirm('Do you want to DELETE ";
js = js + RadGrid1.SelectedIndexes.Count +
" record(s)?')";
Delete.Attributes[
"onclick"] = js;
}
}
I have tried the above in the code behind but the RadGrid1.SelectedIndexes.Count is always 0.
I realize this maybe because the ItemCreated event is triggered before the SelectedIndexChanged event.
|
On server selection from Select/Deselect GridButtonColumn/Auto Postback on row click: |
|
|
For each Item in grid: |
|
|
ItemCreated |
|
|
Page.Load |
|
|
ItemCommand |
|
|
SelectedIndexChanged |
|
|
Other postback events |
|
|
Page.PreRender |
So, is there anyway I can get the count of the selected records and pass it to the confirm javascript when I click on my Delet Selected link button??
Thanks in advance for your advice,
cathy