Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP.NET 2.0 Gridview Popup

    All,
    Here is what I want to accomplish. Currently I have a gridview that I am using to populate data from my SQL Server 2000 DB. The client presses edit which puts the grid into edit mode. They make a change to the dropdownlist in the row and then press Update. Prior to updating I want to check the database to make sure that the value they are selecting has not already been assigned in the database. If it has been assigned I want to show a popup stating that the item they have selected in the dropdown has already been assigned and would they like to continue. If they say yes that they would still like to update then I will assign the value in the database and unassign the previous record putting in its place a null value. Here is the code I am currently using to do this. The problem is that I am using a msgbox function that can only be used on my machine becuase I am running, I assume, in a protected enviromnment that lets me have access to the PC I am coding on from IIS. Hopefully this all makes sense.


    'New Printer value
    Dim sNewPrinter As String = e.NewValues.Item(0)
    'Check to see if printer exists already
    e.NewValues.Item(2) = Session("SAPID")
    Dim SID As String = e.NewValues.Item(2)

    Dim sReturn As String = retAnswer(sNewPrinter)
    Dim sArray() As String = sReturn.ToString().Split("|")
    Dim j As Integer = 0
    Dim sAnswer As String = ""
    Dim sExistStat As String = ""
    sAnswer = sArray(0).ToString()
    sExistStat = sArray(1).ToString()

    If sAnswer = "YES" Then
    If MsgBox("Printer " & sNewPrinter.ToString() & " already exists on " & sExistStat.ToString() & ". Do you still want to update?", MsgBoxStyle.YesNo, "Test Title") = MsgBoxResult.No Then
    e.Cancel = True
    MsgBox("Item was not updated.", MsgBoxStyle.OkOnly, "Item not updated")
    End If
    End If

    TIA

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    MessageBox is Windows Forms.
    Is this a windows forms app, or a web forms app?
    If web forms, you'll have to register a client side script block to accomplish this and use javascript alert.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Feb 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for your reply. This a web app. It does work through VS 2005 but only because it runs the application through the development server which has access to the "desktop". It is new for VS 2005 I believe. I have attempted to work on it through a javascript call from the code-behind but as you can imagine it still attempts to run the server side script.

  • #4
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    Yeah, this architecture won't work on a web app.
    You'll have to use javascript if you want an actual alert. Either register script block or the new onClientClick.

    I prefer to just use a confirmation "page" (just a placeholder control set visible or not) and take the hit of the postback, especially for things where a user might not have javascript enabled and I get a postback anyway, such as gridView updating.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •