473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1585
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: theKirk | last post by:
using Visual Studio 2005 C# ASP.NET I know there has to be a simple way to do this....I want to use C# in a code behind for aspx. Populate a GridView from an xml file Add Fields to the...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
2
by: | last post by:
I want to know how to make a clickable button or Command field on a GridView, and have the user's action a) fire a function and b) pass a data value from one of the GridView's columns to that...
3
by: Richard Carpenter | last post by:
I have a simple winform with a customers combobox, a "get orders" button and an orders grid. Due to other requirements, I have implemented the form to allow the user to select a customer from the...
2
by: Robert | last post by:
I have a question regarding the gridview. Does the gridview persist the entire datasource in the viewstate? For example my datasource is returning 100 records, but my gridview only displays 10....
5
by: NKaufman | last post by:
<asp:GridView ID="Basic" runat="server" DataKeyNames="QuestionID,isHeading" AutoGenerateColumns="false" AllowPaging="true" PageSize="100"> <Columns> <asp:BoundField Visible="false"...
4
by: svgeorge | last post by:
I NEED TO COLLECT FROM THE GRIDVIEW(DATASELECTED) IN TO A TABLE(SelectedPayment) -------------------------------------------------------------------------------- How TO COLLECT THE ROWS...
2
by: frankiefrank | last post by:
I have been struggling with this issue for some time, hope someone here can help out. After facing the issue (will describe it soon) in a solution with Ajax and a Master Page I decided to try it...
5
by: brian | last post by:
I have a gridview that will contain 5000 + rows that is initially loaded into a dataset and bound to a gridview. On the form I have textboxes and dropdown list's I use to let the user fill in and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.