473,804 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Update Database and Redirect to new page

Hello!

I'm fairly new to asp.net and I am struggling with getting my form to
post to the database and transfer the user to a new page. I am using
the FormView control. After the user completes the form, they click the
insert button. The insertbutton has command="insert " which is auto
generated when you use the formcontrol. I tried to add an onclick event
as well that does a server.transfer and it seems the onclick event
overrides the command event. I am redirected to a new page but the
database is not updated. I also tried the onunload event, while it
worked for both redirection and database update, it also put page2 on
page1. So I added an if ispostback to the transfer event and it worked
beautifully! However, I have another button that shows a calendar and
puts the date in textbox and what does that do, it fires a postback, so
I get an error on the page. Hopefully this can be understood. The goal
here is to have the user push a button that will insert data into the
database as well as take the user to a new page. I think the key also
is this should be done using the formview control, from my experience
things work a little differently with in the formview control. Let me
know if I can post more info. Thanks!!

Apr 13 '06 #1
8 2650
Hello Jenileo,

I'm not sure I exactly understand your situation but my guess would be that
you want to handle the FormView.ItemIn serted event. It occurs when an Insert
button within a FormView control is clicked, but after the insert operation.
In the event you could redirect the user to the new page.

--
enjoy - brians
http://www.limbertech.com
"jenileo" wrote:
Hello!

I'm fairly new to asp.net and I am struggling with getting my form to
post to the database and transfer the user to a new page. I am using
the FormView control. After the user completes the form, they click the
insert button. The insertbutton has command="insert " which is auto
generated when you use the formcontrol. I tried to add an onclick event
as well that does a server.transfer and it seems the onclick event
overrides the command event. I am redirected to a new page but the
database is not updated. I also tried the onunload event, while it
worked for both redirection and database update, it also put page2 on
page1. So I added an if ispostback to the transfer event and it worked
beautifully! However, I have another button that shows a calendar and
puts the date in textbox and what does that do, it fires a postback, so
I get an error on the page. Hopefully this can be understood. The goal
here is to have the user push a button that will insert data into the
database as well as take the user to a new page. I think the key also
is this should be done using the formview control, from my experience
things work a little differently with in the formview control. Let me
know if I can post more info. Thanks!!

Apr 13 '06 #2
That is exactly what I want to do! Any suggestions?

Apr 13 '06 #3
Um, he just gave you the suggestion? Your redirect code goes in the
FormView.ItemIn serted event

"jenileo" <je*****@yahoo. com> wrote in message
news:11******** *************@u 72g2000cwu.goog legroups.com...
That is exactly what I want to do! Any suggestions?

Apr 13 '06 #4
Um, I did not realize that? I thought he was reiterating what I was
saying. Must-talk-slowley, I-am-newbie.
I did do the redirect using the formview control and it did not insert
into the database, it only redirected. Here is a snippit, just a
snippit. Maybe I'm not accessing the control correctly? I can post more
code if needed. Thanks in advance for any help that can be offered.
_______________ _______________ _______________ _______________ _______________ _______________ _______________ ____

<%@ Page Language="VB" MasterPageFile= "~/MasterPage.mast er"
EnableViewState ="false" %>

<script language="VB" runat="server">

Sub doSubmit(ByVal Source As Object, ByVal E As
EventArgs)
If IsPostBack Then

Server.Transfer ("newissueconf. aspx")
End If
End Sub

</script>

<asp:Button ID="InsertButto n" runat="server"
CommandName="In sert" onclick="dosubm it" Text="Log Issue" Width="82px"
/>
</InsertItemTempl ate>

</asp:FormView>

</asp:Content>

Apr 13 '06 #5
FormView.ItemIn serted is an actual event handler! Like Onclick.

Jeff

"jenileo" <je*****@yahoo. com> wrote in message
news:11******** **************@ t31g2000cwb.goo glegroups.com.. .
Um, I did not realize that? I thought he was reiterating what I was
saying. Must-talk-slowley, I-am-newbie.
I did do the redirect using the formview control and it did not insert
into the database, it only redirected. Here is a snippit, just a
snippit. Maybe I'm not accessing the control correctly? I can post more
code if needed. Thanks in advance for any help that can be offered.
_______________ _______________ _______________ _______________ _______________ _______________ _______________ ____

<%@ Page Language="VB" MasterPageFile= "~/MasterPage.mast er"
EnableViewState ="false" %>

<script language="VB" runat="server">

Sub doSubmit(ByVal Source As Object, ByVal E As
EventArgs)
If IsPostBack Then

Server.Transfer ("newissueconf. aspx")
End If
End Sub

</script>

<asp:Button ID="InsertButto n" runat="server"
CommandName="In sert" onclick="dosubm it" Text="Log Issue" Width="82px"
/>
</InsertItemTempl ate>

</asp:FormView>

</asp:Content>

Apr 13 '06 #6
Hi Jeff,

Sounds like you are frustrated with me and I really apologize. I can't
stress enough how new I am to this and I am turning to this group for
support. I appreciate your lead and I will do some reading up on
FormView.itemin serted and see if I can figure this out, (that should
tell you how new I am.) Meanwhile, maybe someone else in the group can
offer some pointers and possible sample code. I am a visual learner and
if I see it in the code, I may better understand what Jeff is trying to
explain.

Thanks again Jeff for your help,

Apr 13 '06 #7
If you are using Visual Studio, create a new page and drop a FormView on it.
Then double click on it to get to the code behind, and locate ItemInserted
from the function dropdowns

Jeff

"jenileo" <je*****@yahoo. com> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.com.. .
Hi Jeff,

Sounds like you are frustrated with me and I really apologize. I can't
stress enough how new I am to this and I am turning to this group for
support. I appreciate your lead and I will do some reading up on
FormView.itemin serted and see if I can figure this out, (that should
tell you how new I am.) Meanwhile, maybe someone else in the group can
offer some pointers and possible sample code. I am a visual learner and
if I see it in the code, I may better understand what Jeff is trying to
explain.

Thanks again Jeff for your help,

Apr 13 '06 #8
Thanks for the further explanation. After looking up the information
you provided this solution worked beautifully. I can't believe how much
there is to learn! Thanks again, I greatly appreciate it.

Apr 14 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2410
by: andri.wardhana | last post by:
Hi Guys, I have a problem with my ASP file. since I'm all new in ASP, i found that the error statement generated by ASP is confusing. basically what I want to do in this script is ability to change password. Currently this script's running well in the PHP version ( I rewrote the entire PHP app to ASP app): 1. The form contains these fields : old password, new passwd, confirm new passwd. users have to input old passwd in order to change...
4
2015
by: CaptRR | last post by:
I think this is the right group to post to, so here goes. My problem is this, I cannot update the datarow to save my life. Been on this for 2 days now, and still am no closer to figuring it out than I was before. I'm basicly taking date from some text boxes, trying to put them into a datarow and using that datarow to update the database, but its not working. The btn_update is where I am sending the information back to the addclient...
3
2222
by: D. Shane Fowlkes | last post by:
I have a Datagrid which in theory, should allow you to edit and update the records. I've stripped my test page down so that it's only attempting to update one field - "description". Yet when I make the changes and click Update, it reverts back to the old value. I'm stumped! I've also checked the db table and it is infact not updating. I'm attempting to follow and example right out of ASP.NET Unleashed but not having much luck. Any...
3
1551
by: Terry Olsen | last post by:
I've got 2 different web pages, both updating the same SQL database. One is for the Technician and one is for the Manager. The technician's update page works fine but the Manager's update page doesn't. They are both the same..as far as I can tell... --------------------- This code works fine, updating the SQL database with the edited data. Code for Tech Page
2
1742
by: Roger Withnell | last post by:
The current page has: Response.Write "<a href=""FileDownload.asp?FileNo=" & UbeRS("FileNo") & """>Down</a>" FileDownload.asp has: .. 'Update downloaded file status in ubMgtFiles UbeQ = "UPDATE ubMgtFiles SET Uploaded = NULL, Downloaded = GetDate(), DownBy = " & Session("StaffNo")
1
5186
by: Selvakumar | last post by:
hai friends, I am new to .net programming. I did the inserting data into MS-access database but i couldn't able to perform the update command. I used only textbox and command button for inserting and updating the data. I performed Insert command successfully but i donno y the update command is not working.Pls help.. i ve used all possible update commands. i enclosed all my code( comments also)... Protected Sub Button1_Click(ByVal sender...
5
2482
by: keeps21 | last post by:
A little problem I've run into is the following. I have a script that allows a user to edit a story. I have an HTML form for title and main_text which gets it's values by pulling the selected data from the database. If the user either i) doesn't change anything, and then saves. or
2
2642
by: sirdavethebrave | last post by:
Hi guys - I have written a form, and a stored procedure to update the said form. It really is as simple as that. A user can go into the form, update some fields and hit the update button to update the information which is stored in a SQL database. In testing we noticed that the form was updating correctly but the update mechanism was also updating the first record of the table in the sql database every time. No error messages are on...
4
3929
by: ahling | last post by:
Hi all. As mentioned in my first post, I'm currently doing an asp.net blog where user can update their profile, and update their blog entry. But I encountered problem with the update of entry part. When I tried to post a blog entry by hitting the 'Post' button, it brings me to a blank page which is supposed to show me the gridview that contains the Blog subject, title of the blog entry, date and the name of the poster itself. But what...
0
9712
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10341
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10089
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...
1
7634
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
6862
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
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
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
2
3831
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.