469,927 Members | 1,649 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

Gridview / Form View Question

I am using a Gridview to display a phone directory, with paging on. I have a
link button that a user clicks to add a new record, which reloads the page,
sets the visble property to false on the gridview and shows the form view in
insert mode. Upon saving, the process is reversed. All is well and dandy,
however I want to jump to the page that has the newly entered record, with
the record highlighted. Does anyone know how to do this?
I believe I would need a dataview to find the inserted record and to get
it's row index, but I do not know how to get the dataview from a
SQLDATASOURCE.
Apr 19 '06 #1
3 1457
To all. I figured this one out. I have included my source code for anyone who
may need it:

Protected Sub frmView_ItemInserted(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.FormViewInsertedEventArg s) Handles
frmView.ItemInserted
Dim dv As DataView =
CType(sql.Select(DataSourceSelectArguments.Empty), DataView)
Dim empLoc As String = CType(Session("EmpLoc"), String)
Dim employee As String = CType(Session("Employee"), String)
Dim key(1) As Object
Dim selectKey As Integer = -1
Dim selectPage As Integer = 1

key(0) = empLoc
key(1) = employee

dv.Sort = "EmpLoc, Employee"
selectKey = dv.Find(key)

selectPage = selectKey / gvPhone.PageSize
If selectKey Mod gvPhone.PageSize = 0 Then selectPage -= 1
gvPhone.PageIndex = selectPage
selectKey -= selectPage * gvPhone.PageSize
gvPhone.SelectedIndex = selectKey

Response.Write("selectKey: " + selectKey.ToString + "<br />")
Response.Write("selectPage: " + selectPage.ToString)
End Sub

Protected Sub frmView_ItemInserting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.FormViewInsertEventArgs) Handles
frmView.ItemInserting
Session("EmpLoc") = e.Values.Item(2).ToString
Session("Employee") = e.Values.Item(1).ToString
End Sub

Tahnks...

"John Daly" wrote:
I am using a Gridview to display a phone directory, with paging on. I have a
link button that a user clicks to add a new record, which reloads the page,
sets the visble property to false on the gridview and shows the form view in
insert mode. Upon saving, the process is reversed. All is well and dandy,
however I want to jump to the page that has the newly entered record, with
the record highlighted. Does anyone know how to do this?
I believe I would need a dataview to find the inserted record and to get
it's row index, but I do not know how to get the dataview from a
SQLDATASOURCE.

Apr 19 '06 #2
John Daly wrote:
To all. I figured this one out. I have included my source code for anyone who
may need it:

Protected Sub frmView_ItemInserted(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.FormViewInsertedEventArg s) Handles
frmView.ItemInserted
Dim dv As DataView =
CType(sql.Select(DataSourceSelectArguments.Empty), DataView)
Dim empLoc As String = CType(Session("EmpLoc"), String)
Dim employee As String = CType(Session("Employee"), String)
Dim key(1) As Object
Dim selectKey As Integer = -1
Dim selectPage As Integer = 1

key(0) = empLoc
key(1) = employee

dv.Sort = "EmpLoc, Employee"
selectKey = dv.Find(key)

selectPage = selectKey / gvPhone.PageSize
If selectKey Mod gvPhone.PageSize = 0 Then selectPage -= 1
gvPhone.PageIndex = selectPage
selectKey -= selectPage * gvPhone.PageSize
gvPhone.SelectedIndex = selectKey

Response.Write("selectKey: " + selectKey.ToString + "<br />")
Response.Write("selectPage: " + selectPage.ToString)
End Sub

Protected Sub frmView_ItemInserting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.FormViewInsertEventArgs) Handles
frmView.ItemInserting
Session("EmpLoc") = e.Values.Item(2).ToString
Session("Employee") = e.Values.Item(1).ToString
End Sub

Tahnks...

"John Daly" wrote:
I am using a Gridview to display a phone directory, with paging on. I have a
link button that a user clicks to add a new record, which reloads the page,
sets the visble property to false on the gridview and shows the form view in
insert mode. Upon saving, the process is reversed. All is well and dandy,
however I want to jump to the page that has the newly entered record, with
the record highlighted. Does anyone know how to do this?
I believe I would need a dataview to find the inserted record and to get
it's row index, but I do not know how to get the dataview from a
SQLDATASOURCE.


but, John, you only gave us 40 minutes ;)

--
Craig
Microsoft MVP - ASP/ASP.NET
Apr 19 '06 #3
Hey Craig, 40 minutes is along time... :)
Next time, I'll give you 42 minutes...
"Craig Deelsnyder" wrote:
John Daly wrote:
To all. I figured this one out. I have included my source code for anyone who
may need it:

Protected Sub frmView_ItemInserted(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.FormViewInsertedEventArg s) Handles
frmView.ItemInserted
Dim dv As DataView =
CType(sql.Select(DataSourceSelectArguments.Empty), DataView)
Dim empLoc As String = CType(Session("EmpLoc"), String)
Dim employee As String = CType(Session("Employee"), String)
Dim key(1) As Object
Dim selectKey As Integer = -1
Dim selectPage As Integer = 1

key(0) = empLoc
key(1) = employee

dv.Sort = "EmpLoc, Employee"
selectKey = dv.Find(key)

selectPage = selectKey / gvPhone.PageSize
If selectKey Mod gvPhone.PageSize = 0 Then selectPage -= 1
gvPhone.PageIndex = selectPage
selectKey -= selectPage * gvPhone.PageSize
gvPhone.SelectedIndex = selectKey

Response.Write("selectKey: " + selectKey.ToString + "<br />")
Response.Write("selectPage: " + selectPage.ToString)
End Sub

Protected Sub frmView_ItemInserting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.FormViewInsertEventArgs) Handles
frmView.ItemInserting
Session("EmpLoc") = e.Values.Item(2).ToString
Session("Employee") = e.Values.Item(1).ToString
End Sub

Tahnks...

"John Daly" wrote:
I am using a Gridview to display a phone directory, with paging on. I have a
link button that a user clicks to add a new record, which reloads the page,
sets the visble property to false on the gridview and shows the form view in
insert mode. Upon saving, the process is reversed. All is well and dandy,
however I want to jump to the page that has the newly entered record, with
the record highlighted. Does anyone know how to do this?
I believe I would need a dataview to find the inserted record and to get
it's row index, but I do not know how to get the dataview from a
SQLDATASOURCE.


but, John, you only gave us 40 minutes ;)

--
Craig
Microsoft MVP - ASP/ASP.NET

Apr 19 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Richard Carpenter | last post: by
2 posts views Thread by Robert | last post: by
5 posts views Thread by NKaufman | last post: by
5 posts views Thread by brian | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.