[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Code works in VS2003 but not in VS2005

Posted on 2006-05-09
Medium Priority
Last Modified: 2008-05-09
I have an aspx page in Visual Studio 2003 with a datagrid on it. I have the next code for highlighting the grid row when the mouse is over and then when the user clicks on the row it takes a copule of parameters (IdArea, AreaName) and redirects the browser to another aspx page.
This code works very well in VS2003 but I recently migrated this project to VS2005 and it does not work anymore, I tried to make it work but it seems I can't do it. What is happening (I suppose) is that the DataGrid1_SelectedIndexChanged event is not firing when the user clicks on the datagrid row so I have a page postback but no redirection at all.

Does anyone has any idea why this code stopped working ??
I would appreciate any help in this matter.
Thank you


    Private Sub DataGrid1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid1.SelectedIndexChanged
        DataGrid1.SelectedItem.Attributes.Item("onmouseover") = "this.style.cursor='hand'"
        '--Redirect to WebForm2
        Dim url As String
        url = "WebForm2.aspx?IdArea=" + DataGrid1.SelectedItem.Cells(0).Text + "&AreaName=" + DataGrid1.SelectedItem.Cells(1).Text
    End Sub

    Private Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemCreated
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.SelectedItem Then
            e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#D8E4F8';this.style.cursor='hand'")
            e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white';")
            e.Item.Attributes.Add("onclick", "javascript:__doPostBack('" & "DataGrid1:" & "_ctl" & (e.Item.ItemIndex + 3) & ":_ctl0','')")
        End If
    End Sub
Question by:Temujin
  • 2
LVL 19

Assisted Solution

MsShadow earned 450 total points
ID: 16645715
You should post the entire asp.net page cause then we can see where the actual event is defined. Sometimes when these things dont work anymore it helps to just take to control, go to properties/events and then select the event again in the list. It might be that the link between the 2 just broke down.

Accepted Solution

nehaya earned 450 total points
ID: 16645880
Is there DataGrid in 2005?
As I know, it's totally replaced with another control: 'GridView'..
I don't know, maybe it's still supported.


Author Comment

ID: 16654746
Thank you MsShadow and nehaya for your comments.
I'll be on a little work trip and I'll return on monday may, 15. I will retake this problem and i'll get back to you. I'll check your comments then.

Author Comment

ID: 16723163
Sorry for the delay, trip took longer than i tought.
I didn´t have any time to test your comments but i must close this question since it didn't raise any other comments, so i think you both are right.
Thank you guys.


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month20 days, 4 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question