Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 8th, 2005, 07:44 AM
Authorized User
 
Join Date: Dec 2005
Location: , , .
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to raybristol
Default a problem of adding a confirm window to delete but

hi i have a template column in datagrid, i have a button in header template, checkbox for itemtemplate, so i can delete multiple rows, my code works fine for that but I need to tell user what items will be deleted before they press 'OK' button in the popup windows, i have a problem of collecting selected item's ID, in my code, the selected item's ID only will be collected after user press 'OK' button in the popup window. my code for aspx page is in below:

<asp:TemplateColumn HeaderText="Delete" HeaderStyle-Width=70px>
<HeaderTemplate>
'DeleteStore will look for checked item and perform delete
<asp:button id=delConfirm onclick=DeleteStore runat="server" Width="62px" Text="Reject" Font-Bold=True ></asp:button>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox id=DeleteThis Runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>


in DeleteStore I use following code to search all the checked checkbox:

   For Each i As DataGridItem In DataGrid1.Items
      Dim deleteChkBxItem As CheckBox = CType(i.FindControl("DeleteThis"), CheckBox)
'delIDs will be assigned selected item's ID
                      If deleteChkBxItem.Checked Then
                          delIDs += CType(i.FindControl("Hyperlink8"), HyperLink).Text.ToString + ","
'Label5.Text is for debugging purpose
                          Label5.Text = delIDs
                      End If
Next

however, I want to put all the selected item information in the popup confirm window, which will be the value of delIDs, however if I put above code combine with the popup confirm window code like this:

Private Sub DataGrid1_ItemGreated(ByVal Sender As Object, ByVal e As DataGridItemEventArgs) Handles DataGrid1.ItemCreated
      Select Case e.Item.ItemType
          Case ListItemType.Item, ListItemType.AlternatingItem, ListItemType.EditItem, ListItemType.Header
              Dim myDeleteButton As WebControl
              myDeleteButton = e.Item.FindControl("delConfirm")

              If myDeleteButton Is Nothing Then
              Else

   'I dun know why this for loop is run after "return confirm...

                  For Each i As DataGridItem In DataGrid1.Items
                      Dim deleteChkBxItem As CheckBox = CType(i.FindControl("DeleteThis"), CheckBox)

                      If deleteChkBxItem.Checked Then
                          delIDs += CType(i.FindControl("Hyperlink8"), HyperLink).Text.ToString + ","
                          Label5.Text = delIDs
                      End If
                  Next



                  myDeleteButton.Attributes.Add("onclick", "return confirm('Are you sure you want to delete the following News? " + delIDs + " ');")

              End If
      End Select
      chkState()
  End Sub


in above code, statement " myDeleteButton.Attributes.Add("onclick", "return confirm('Are you sure you want to delete the following News? " + delIDs + " ');")" is for adding the confirm window before delete action, it suppose to display all the selected item's ID (delIDs) in the popup window, however, delIDs is not assigned with selected items' ID until I press ok in the confirm window (I can see this by viewing Lable5's text, because I also assign Lable5's text = delIDs)

I hope this is clear, thanks so much for your help!


Reply With Quote
  #2 (permalink)  
Old December 12th, 2005, 04:50 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

This is a server-side/client-side problem. You don't know what rows the user will select to delete when you are rendering the controls and creating the delete prompts. If you make the checkboxes do autopostbacks, then you could re-write the button's click script with the confirm, but this would mean you have to do a full postback for each little checkbox and that's not too efficient.

This problem may have to be solved with a client-side solution. You'll need to write some javascript to look at the checkbox controls and possibly the table that is rendered by the datagrid in order to do what you want without the checkbox postbacks. Some javascript and DHTML information will help you with that task.

-Peter
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
a problem of adding a confirm window to delete but raybristol ASP.NET 1.0 and 1.1 Basics 1 December 12th, 2005 05:01 PM
Confirm delete row in datagrid rajanikrishna General .NET 3 December 8th, 2004 09:27 PM
Confirm Window AND email sent Ames2004 ASP.NET 1.0 and 1.1 Basics 4 May 24th, 2004 03:38 PM



All times are GMT -4. The time now is 01:01 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.