• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 367
  • Last Modified:

Calling window.open and passing parameter within datagrid itemdatabound

Hello experts,  I have a itemdatabound procedure for my datagrid, I am dynamically changing the image in one of the cells dependent on a cell text. I want to be able to open a new webpage and pass a parameter when a user clicks on the image. I am trying the window.open function and it works fine without parameters, but I can not seem to get the syntax down to pass a parameter.  If you look at the 2nd select case Case "1" I am trying to pass a parameter called pressname.  I was able to pass "pressname" but not the value of the variable.  How can i make this work?

 Private Sub dgstatus_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgstatus.ItemDataBound
        If Not (e.Item.ItemType = ListItemType.Header Or e.Item.ItemType = ListItemType.Footer) Then
            Dim pressname, dhold As String
            pressname = e.Item.Cells(1).Text
            Select Case pressname
                Case "Gwn_4000"
                    pressname = "4000 ton"
                Case "Gwn_1500"
                    pressname = "1500 ton"
            End Select
            Select Case e.Item.Cells(0).Text
                Case "0"
                    dhold = "<a onmouseover=this.style.cursor='hand'; onclick=window.open('Gwn_Press_Current.aspx?press_val=" + pressname + "','cal','width=700,height=200,left=50,top=215')><IMG alt=''  border=0 src='images\greenlight.gif'></a>"
                Case "1"
                    dhold = "<a onmouseover=this.style.cursor='hand'; onclick=window.open('Gwn_Press_Current.aspx','cal','width=700,height=200,left=50,top=215')><IMG alt='' border=0 src='imagesprime\alert2.gif'></a>"
            End Select
            'e.Item.Cells(0).Text = "<a style='COLOR: blue;' target=_blank href=comments.aspx?cell=" + cellname + "&shift=" + shift + "&dateval=" + dhold + ">View Comments</a>"
            e.Item.Cells(0).Text = dhold
            e.Item.Cells(1).Text = pressname
        End If
    End Sub
0
tentavarious
Asked:
tentavarious
1 Solution
 
vinodhsomasekharanCommented:

Hai,

I tried u r code..

it worked if u make a slight change in u r code..

u have used

onclick= window.open('Gwn_Press_Current.aspx?press_val=" + pressname + 'cal','width=700,height=200,left=50,top=215')

just put
1.  ""  -- near window.open(
2. ;"" -- after top=215')
       
onclick= ""window.open('Gwn_Press_Current.aspx?press_val=" + pressname + 'cal','width=700,height=200,left=50,top=215');""

Try this..

regards
Vinu


0
 
tentavariousAuthor Commented:
I tried doing what you had, but it seems like your missing a closing ", anyways I have a little javascript function that makes the cursor a hand.  Here is my complete code:  The second case with case 0 is your example.  Case 1 is the working example that doesnt actually pass the value of the variable.

 Private Sub dgstatus_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgstatus.ItemDataBound
        If Not (e.Item.ItemType = ListItemType.Header Or e.Item.ItemType = ListItemType.Footer) Then
            Dim pressname, dhold As String
            pressname = e.Item.Cells(1).Text
            Select Case pressname
                Case "Gwn_4000"
                    pressname = "4000 ton"
                Case "Gwn_1500"
                    pressname = "1500 ton"
            End Select
            Select Case e.Item.Cells(0).Text
                Case "0"
                    dhold = "<a onmouseover=this.style.cursor='hand'; onclick=""window.open('Gwn_Press_Current.aspx?press_val=" + pressname + ",'cal','width=700,height=200,left=50,top=215');""><IMG alt=''  border=0 src='images\greenlight.gif'></a>"
                Case "1"
                    dhold = "<a onmouseover=this.style.cursor='hand'; onclick=window.open('Gwn_Press_Current.aspx?press_val=pressname','cal','width=700,height=200,left=50,top=215')><IMG alt='' border=0 src='imagesprime\alert2.gif'></a>"
            End Select
            'e.Item.Cells(0).Text = "<a style='COLOR: blue;' target=_blank href=comments.aspx?cell=" + cellname + "&shift=" + shift + "&dateval=" + dhold + ">View Comments</a>"
            e.Item.Cells(0).Text = dhold
            e.Item.Cells(1).Text = pressname
        End If
    End Sub
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now