473,757 Members | 10,754 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1598
To all. I figured this one out. I have included my source code for anyone who
may need it:

Protected Sub frmView_ItemIns erted(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Form ViewInsertedEve ntArgs) Handles
frmView.ItemIns erted
Dim dv As DataView =
CType(sql.Selec t(DataSourceSel ectArguments.Em pty), 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.PageSiz e
If selectKey Mod gvPhone.PageSiz e = 0 Then selectPage -= 1
gvPhone.PageInd ex = selectPage
selectKey -= selectPage * gvPhone.PageSiz e
gvPhone.Selecte dIndex = selectKey

Response.Write( "selectKey: " + selectKey.ToStr ing + "<br />")
Response.Write( "selectPage : " + selectPage.ToSt ring)
End Sub

Protected Sub frmView_ItemIns erting(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Form ViewInsertEvent Args) Handles
frmView.ItemIns erting
Session("EmpLoc ") = e.Values.Item(2 ).ToString
Session("Employ ee") = 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_ItemIns erted(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Form ViewInsertedEve ntArgs) Handles
frmView.ItemIns erted
Dim dv As DataView =
CType(sql.Selec t(DataSourceSel ectArguments.Em pty), 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.PageSiz e
If selectKey Mod gvPhone.PageSiz e = 0 Then selectPage -= 1
gvPhone.PageInd ex = selectPage
selectKey -= selectPage * gvPhone.PageSiz e
gvPhone.Selecte dIndex = selectKey

Response.Write( "selectKey: " + selectKey.ToStr ing + "<br />")
Response.Write( "selectPage : " + selectPage.ToSt ring)
End Sub

Protected Sub frmView_ItemIns erting(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Form ViewInsertEvent Args) Handles
frmView.ItemIns erting
Session("EmpLoc ") = e.Values.Item(2 ).ToString
Session("Employ ee") = 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_ItemIns erted(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Form ViewInsertedEve ntArgs) Handles
frmView.ItemIns erted
Dim dv As DataView =
CType(sql.Selec t(DataSourceSel ectArguments.Em pty), 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.PageSiz e
If selectKey Mod gvPhone.PageSiz e = 0 Then selectPage -= 1
gvPhone.PageInd ex = selectPage
selectKey -= selectPage * gvPhone.PageSiz e
gvPhone.Selecte dIndex = selectKey

Response.Write( "selectKey: " + selectKey.ToStr ing + "<br />")
Response.Write( "selectPage : " + selectPage.ToSt ring)
End Sub

Protected Sub frmView_ItemIns erting(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Form ViewInsertEvent Args) Handles
frmView.ItemIns erting
Session("EmpLoc ") = e.Values.Item(2 ).ToString
Session("Employ ee") = 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
5677
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 GridView to allow entry of quantity and Y/N switch for
7
14816
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 want to look at that data and filter it based on what is in it. I know that this could have been done with data sets and data views in asp.net 1.1 but how is this done now in asp.net 2.0?
2
2444
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 function. Long version: ASP.NET's usual paradigm with master-detail editing is to have you define a commandfield, and on your detail view to define a second datasource that uses the SelectedValue of the GridView to determine what the detail record...
3
1979
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 combobox and click the "get orders" button to refresh the gridview with the selected customer's orders, via a GetDataByCustomerID stored procedure. The underlying Orders table includes, among others, three boolean columns and one particular...
2
1337
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. Are the other 90 records stored in the viewstate? Thanks.
5
23632
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" DataField="QuestionID" HeaderText="QuestionID"></asp:BoundField> <asp:BoundField DataField="QuestionDesc" HeaderText="Question" ItemStyle-HorizontalAlign="Left"></ asp:BoundField>
4
1978
by: svgeorge | last post by:
I NEED TO COLLECT FROM THE GRIDVIEW(DATASELECTED) IN TO A TABLE(SelectedPayment) -------------------------------------------------------------------------------- How TO COLLECT THE ROWS CHECKED IN CHECK BOX IN THE DATASELECTED TO ANOTHER GRID VIEW ON CLICLING BUTTON I NEED TO COLLECT FROM THE GRIDVIEW(DATASELECTED) IN TO A TABLE(SelectedPayment) SIMILLAR TO HOTMAIL MODEL.....CHECK THE MAILS AND BRING THE CHECKED DATA TO ANOTHER PAGE
2
4721
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 in its most basic form: I created a new project, new aspx page with a GridView. I notice that once I create the new page the body contains a <form runat="server"> tag. I add a GridView, data comes from SQL server. I want to be able to render the...
5
270
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 click an add button to add new records. As I let users add records I update the SQL backend (insert a record). I want to programattically add a row to the gridview an not having to requery the table reload the dataset and bind each time a...
0
10072
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6562
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.