473,408 Members | 2,009 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,408 software developers and data experts.

How to redirect to another url when Edit (option in gridview) is clicked?

Ewan
18
Hi

Im using Visual Studio 2008, i have a gridview which gets data from an SQL table. I have added the Edit option which is part of gridview.
The data has a primary key set.

How do i redirect to another URL when the edit option is clicked.
This action should also assign the primary key as a URL Parameter, causing only that specific record to show on the Edit page.

I have gone through this article: http://bytes.com/topic/asp-net/answe...field-gridview
However im not able to understand how to do this.
Feb 23 '11 #1

✓ answered by Ewan

i have updated the following in the Code Behind for the RowEditing event.
it works just fine :)

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub gridview1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gridview1.RowEditing
  3.         Session("wr_id") = gridview1.Rows(e.NewEditIndex).Cells(2).Text
  4.         Response.Redirect("EditRecord.aspx")
  5.     End Sub
  6.  
what im doing here is moving the required data from the gridview into a Session
(please refer to Article: http://bytes.com/topic/asp-net/insig...ween-web-pages on how to pass parameters using sessions)
and then redirecting to the page where i need that required parameter to be displayed :).
(You should have already updated the code behind to show the data captured in the session)
Example: I updated the code behind for the EditRecord.aspx.vb as below
Expand|Select|Wrap|Line Numbers
  1.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.         Dim ID As String = Session("wr_id")
  3.  
  4.         lblReq.Text = "The parameter you have just transfered is " + ID
  5.  
  6.     End Sub
  7.  

4 6913
Ewan
18
For information:
To add the edit button i have done the following:

In GridView tasks go to:
Edit Columns>Available Fields:>CommandField>Edit,Update,Cancel
select Add

This will display an edit button for each row on the GridView
Feb 23 '11 #2
Ewan
18
I have found the resolusion @
http://bytes.com/topic/asp-net/answe...f-i-click-edit

:)
Feb 26 '11 #3
Ewan
18
:( UNFORTUNATELY - when i click on Edit it takes the value from the selected Row,
so if i select the 2nd Row and click on edit for the 4th Row, i get the value for the 2nd Row and not the 4th.
how do i select a row automatically when Edit option for that corresponsing row is clicked.
Please help
Feb 28 '11 #4
Ewan
18
i have updated the following in the Code Behind for the RowEditing event.
it works just fine :)

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub gridview1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles gridview1.RowEditing
  3.         Session("wr_id") = gridview1.Rows(e.NewEditIndex).Cells(2).Text
  4.         Response.Redirect("EditRecord.aspx")
  5.     End Sub
  6.  
what im doing here is moving the required data from the gridview into a Session
(please refer to Article: http://bytes.com/topic/asp-net/insig...ween-web-pages on how to pass parameters using sessions)
and then redirecting to the page where i need that required parameter to be displayed :).
(You should have already updated the code behind to show the data captured in the session)
Example: I updated the code behind for the EditRecord.aspx.vb as below
Expand|Select|Wrap|Line Numbers
  1.     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.         Dim ID As String = Session("wr_id")
  3.  
  4.         lblReq.Text = "The parameter you have just transfered is " + ID
  5.  
  6.     End Sub
  7.  
Mar 1 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Oskar Wild | last post by:
Hello, how do I code it to display a select (pulldown) box only if the user has selected a certain option in another pulldown box? <select name=country> <OPTION value="France" SELECTED>France...
0
by: Stanley J Mroczek | last post by:
How do load a dropdownlist when edit is clicked in a datagrid and mark the selected item true? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
3
by: Jason | last post by:
I am new to WebForms and am far more comfortable with WinForms. I am wondering how simple things such as showing/hiding a label and textbox can be accomplished if a certain Radiobutton option is...
1
by: Mark Rae | last post by:
Guys, Apologies for asking this, but it's late and I'm clearly missing something fairly obvious... I have an <asp:DataGrid > control defined thus: <asp:DataGrid ID=dgrdResults Runat=server...
2
by: chitrapu | last post by:
hiii everybody, i have a little code that inserts the data into the databse. but the problem is the insertion should be peroformed only when a button is clicked. i have problems in this because i...
2
by: ruthie | last post by:
Hi, I have a gridview with edit option. If the user chooses to edit the row and then press the Cancel button - I would like the focus to return to the chosen row. Someone has any idea how to...
0
by: vbrookie | last post by:
Hi. I am experiencing some bug/error trying to add/modify a hyperlink in a subform. The field is linked to a table that is designated as a hyperlink datatype. While accessing the form and...
4
by: stitch121103 | last post by:
I'm working on asomething that has an image map with multiple hotspots. When the hotspot is clicked, I need it to highlight a particular row in the table that gives information about the person that...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...

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.