Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Re: delete confirmation in datagrid

Reply
Thread Tools

Re: delete confirmation in datagrid

 
 
sramruttun
Guest
Posts: n/a
 
      07-04-2003
thanks Vidar - I'll try it and give u a feedback.

"Vidar Petursson" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Hi
>
> Make a function on the client that checks if any checkbox is checked...
>
> Basic example ( Should work in most browsers )
> <html>
> <head>
> <script language="JavaScript">
> function checkIt(f){
> var e = f.elements;
> var l = ( typeof(e.length) == "undefined") ? 0 : e.length;
> var iCount = 0;
> for(i=0;i<l;i++)
> {
> if(e[i].type == "checkbox") if(e[i].checked) iCount++;
> }
> if(iCount == 0 )
> {
> alert("Please select items to delete!");
> return false;
> }
> else return confirm("Delete selectet item(s)?");
> }
> </script>
> </head>
> <body>
> <form name="myForm">
> <input type="checkbox" name="myCheckBox">
> <input type="submit" onclick="return checkIt(this.form)" value="Check if
> checkbox checked">
> </form>
> </body>
> </html>
>
> Hope this helps!!
>
> --
> Best Regards
> Vidar Petursson
> ==============================
> Microsoft Internet Client & Controls MVP
> ==============================
> "sramruttun" <(E-Mail Removed)> wrote in message
> news:%235w$(E-Mail Removed)...
> > hi
> > I have a datagrid with 4 columns. 1st col shows the client code, 2nd col
> > shows the client name, 3rd col shows his address and the 4th is a

template
> > col in which I have a delete button (in fact it is an imagebutton) in

the
> > header section and checkboxes in the item section. The idea is to select

1
> > or more clients and then delete. Then I added a delete confirmation

> message
> > to the button as follows:
> >
> > In the ItemCreated event of the datagrid:
> > If e.Item.ItemType = ListItemType.Header Then
> > Dim DelButton As ImageButton = CType(e.Item.FindControl("ImgDel"),
> > ImageButton)
> > DelButton.Attributes.Add("onclick", "return confirm('Are you sure you

> want
> > to delete the selected item(s)?');")
> > endif
> >
> > In HTML Source of the .aspx:
> > <asp:TemplateColumn> <HeaderTemplate>
> > <asp:ImageButton id="ImgDel" onClick="Delete_Items" runat="server"
> > CausesValidation="False" ImageUrl="Images/del.gif">
> > </asp:ImageButton> </HeaderTemplate>
> >
> >
> > The sub Delete_Items:
> > Protected Sub Delete_Items(ByVal sender As Object, ByVal e As
> > System.Web.UI.ImageClickEventArgs)
> > Dim oItem As DataGridItem
> > Dim sKeys As New ArrayList
> >
> > For Each oItem In DataGrid1.Items
> > If CType(oItem.FindControl("chkDel"), CheckBox).Checked Then
> > sKeys.Add(DataGrid1.DataKeys(oItem.ItemIndex))
> > End If
> > Next
> >
> > If sKeys.Count <> 0 Then
> > DeleteClient(sKeys) 'This sub does the actual deletion
> > End If
> > End Sub
> >
> > This technique works. The problem is that if I click the Delete button

> even
> > if I've not checked any of the checkboxes, it asks me for the delete
> > confirmation. Do u think there's a way to skip this if no items are

> checked?
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Client Side Confirmation on DataGrid "Delete" LinkButton =?Utf-8?B?QWxleCBNYWdoZW4=?= ASP .Net 8 11-23-2010 09:45 PM
Adding a confirmation pop-up window for datagrid delete Elton W ASP .Net 0 05-15-2005 08:47 PM
how to implement delete confirmation in datagrid DrData ASP .Net 4 03-22-2005 06:32 AM
How to use confirmation box on delete a row in a datagrid? JenHu ASP .Net 6 02-03-2005 01:31 AM
Datagrid Item Delete Confirmation not working Nedu N ASP .Net 2 12-04-2003 02:16 AM



Advertisments