This is a migrated thread and some comments may be shown as answers.

Running SelectedIndexChange Code twice

1 Answer 42 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ryan
Top achievements
Rank 1
Ryan asked on 31 Aug 2012, 12:52 PM
Hi,
I have a radgrid that is opening a new radwindow when i click on any row using this code...

Protected Sub RadGrid1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles RadGrid1.SelectedIndexChanged
    If RadGrid1.SelectedItems.Count > 0 Then
        For Each item As GridDataItem In RadGrid1.SelectedItems
            Dim strid As String
            strid = item("UniqueID").Text
            Session("Selected") = "Selected"
            Session("ID") = strid
            'Response.Redirect("MessageForm1.aspx")
            'Dim script As String
            'script = "<script type='text/javascript'>"
            'script += "Message();"
            'script += "</" + "script>"
            'InjectScript.Text = "<script type='text/javascript'>Return Message();</" + "script>"
            Dim newwindow As New RadWindow
            newwindow.NavigateUrl = "MessageForm1.aspx"
            RadWindow1.Windows.Add(newwindow)
            newwindow.Width = Unit.Pixel(600)
            newwindow.Height = Unit.Pixel(650)
            newwindow.Title = "Message"
        Next
    End If
End Sub
This works fine, except one thing...
It runs twice which gives me two instances of "newwindow"

how do i stop it running twice?
Thanks
Ryan

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 05 Sep 2012, 06:09 AM
Hi Ryan,

Could you please verify that you are not attaching the SelectedIndexChanged event twice. Once into the page markup and once into the code behind by using the "Handles RadGrid1.SelectedIndexChanged"?

Looking forward for your reply.

All the best,
Radoslav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Window
Asked by
Ryan
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or