?
Solved

Gridview Selected Index Changed

Posted on 2011-10-13
8
Medium Priority
?
385 Views
Last Modified: 2012-05-12
I have an aspx page that has a gridview and a form view.

When the page loads the gridview is filled with data.

When a user selects a row in the grid view i want the form view to be updated to that record.

Here is what I am trying

In the GridView1_SelectedIndexChanged... But it does not work... Any Ideas?

Thanks

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        MsgBox("It was selected")
        FormView1.DataBind()

    End Sub
0
Comment
Question by:Wildone63
  • 4
  • 4
8 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36965429
How do you select the row? Do you have a Select column?
0
 
LVL 1

Author Comment

by:Wildone63
ID: 36965465
Yes there is a select row column
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36965530
Then the selectedindexchanged event should fire. Have you put a breakpoint on it to see if it is?
0
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.

 
LVL 1

Author Comment

by:Wildone63
ID: 36965538
Yes, and it is firing

so I have this The msgbox tells me the event fired, then I am doing the formview1.databind, but the formview does not update to the selected record.


    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
        MsgBox("It was selected")
        FormView1.DataBind()

    End Sub
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 36965567
How does formview know what record to show?
0
 
LVL 1

Author Comment

by:Wildone63
ID: 36965576
Well I am not sure, I was assuming because both the formview and the dataview are using the same sql data source
0
 
LVL 1

Author Comment

by:Wildone63
ID: 36965598
I got it.

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        Dim RowIndex As Integer = Convert.ToInt16(e.CommandArgument.ToString)

        Dim gv As GridView = CType(sender, GridView)
        Dim PgIndex As Integer = gv.PageIndex

        Dim PgSize As Integer = gv.PageSize
        FormView1.PageIndex = RowIndex + (PgIndex * PgSize)

        FormView1.DataBind()

    End Sub
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 36965669
Cool
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Loops Section Overview
Suggested Courses
Course of the Month16 days, 18 hours left to enroll

862 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