[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.2

Gridview row onclick call sub procedure in code behind

Asked by rss2 in Programming for ASP.NET, Microsoft Visual Basic.Net

Tags: gridview, onclick, row

Hi experts,

I have a vb.net page with a gridview on it.

I have successfully set it up so when the mouse hovers over a row, the background row color changes. But now, I want to be able to click on the row and call a subroutine in the code behind page.

So essentially, I have a sub procedure in my code behind code called SelectedRow(ByVal QueryId as Integer)

So I want to set up the OnClick event (I'm using ASP.NET v2.0 by the way) so that when the user clicks on the row, it calls the SelectedRow sub procedure.

Here is my code so far:
Protected Sub GridView1_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowCreated
        If e.Row.RowType = DataControlRowType.DataRow Then
            Dim dv As DataRowView = CType(e.Row.DataItem, DataRowView)
            Dim str As String = "javascript:__doPostBack('" + GridView1.UniqueID.ToString + "','" + e.Row.RowIndex.ToString + "')"

            e.Row.Attributes.Add("onmouseover", "this.oldClassName=this.className;this.className='gridviewContentHover';this.style.cursor='pointer';")
            e.Row.Attributes.Add("onmouseout", "this.className='gridviewContent'")
            'Dim strUrl As String = CStr(GridView1.DataKeys(e.Row.RowIndex))
            Dim strUrl As String = CStr(GridView1.DataKeys(e.Row.RowIndex).Item(0).ToString)

            'e.Row.Attributes.Add("OnClick", "window.location.href='homepage.aspx?rowid=" & CStr(GridView1.DataKeys(e.Row.RowIndex).Item(0).ToString) & "';")
            e.Row.Attributes.Add("OnClick", str) '"SelectedRow()") '"SelectedRow(" & CStr(GridView1.DataKeys(e.Row.RowIndex).Item(0).ToString) & ")")


        End If
    End Sub

I really don't want to use javascript but I suppose I will if I must.

Thanks! This is super duper urgent!

rss2
 
Related Solutions
Keywords: Gridview row onclick call sub procedu…
 
Loading Advertisement...
 
[+][-]06/25/07 08:36 AM, ID: 19356532Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: Programming for ASP.NET, Microsoft Visual Basic.Net
Tags: gridview, onclick, row
Sign Up Now!
Solution Provided By: culshaja
Participating Experts: 1
Solution Grade: A
 
[+][-]06/25/07 07:45 AM, ID: 19356024Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06/25/07 07:47 AM, ID: 19356040Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06/26/07 02:28 AM, ID: 19361983Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07/21/07 04:21 AM, ID: 19538105Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92