Wildone63
asked on
Gridview Selected Index Changed
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_SelectedIndexCha nged... But it does not work... Any Ideas?
Thanks
Protected Sub GridView1_SelectedIndexCha nged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexCha nged
MsgBox("It was selected")
FormView1.DataBind()
End Sub
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_SelectedIndexCha
Thanks
Protected Sub GridView1_SelectedIndexCha
MsgBox("It was selected")
FormView1.DataBind()
End Sub
How do you select the row? Do you have a Select column?
ASKER
Yes there is a select row column
Then the selectedindexchanged event should fire. Have you put a breakpoint on it to see if it is?
ASKER
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_SelectedIndexCha nged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexCha nged
MsgBox("It was selected")
FormView1.DataBind()
End Sub
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_SelectedIndexCha
MsgBox("It was selected")
FormView1.DataBind()
End Sub
How does formview know what record to show?
ASKER
Well I am not sure, I was assuming because both the formview and the dataview are using the same sql data source
ASKER
I got it.
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls. GridViewCo mmandEvent Args) Handles GridView1.RowCommand
Dim RowIndex As Integer = Convert.ToInt16(e.CommandA rgument.To String)
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
Protected Sub GridView1_RowCommand(ByVal
Dim RowIndex As Integer = Convert.ToInt16(e.CommandA
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.