Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert and return to another page

Status
Not open for further replies.

Nesscafe

Programmer
Aug 1, 2006
19
RO
hi. i have a small problem with a formview that has insert/update/delete methods the default ones. my problem is with the insert command/button, that actes ok if i leave it like it is, but i want to redirect the page after the insert command executs and stores the "thead", but when i use the urlpostback="x.aspx" or the Server.Transfer("x.aspx"); code it redirects me to the x.aspx page but without inserting into the data base what i have wrighten.
and one more thing i have a script that checks if all the fields ar empty or no. here's the code:

<script language="C#" runat=server>
void ValidateBtn_Click(Object Sender, EventArgs E) {

if (Page.IsValid == true) {
lblOutput.Text = "thread loaded";
}

else {
lblOutput.Text = "fields are empty";
}


}

</script>

and the insert button code:

<asp:LinkButton ID="InsertButton" OnClick="ValidateBtn_Click" runat="server" CommandName="Insert" Font-Bold="True" Text="Insert" Width="37px"></asp:LinkButton>

how can i get this to work? if i didnt explain very well, what the problem is, im sorry.

thanks in advence for any help.
 
first try was Sistem.transfer ("x.aspx")
second was postbackurl="x.aspx"

btw i'm using visual studio 2005.
thx
 
ok show the code in your code behind page. Show the event where you put the codet.. etc.
 
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class formular : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}


void ValidateBtn_Click(Object Sender, EventArgs E)
{

if (Page.IsValid == true)
{
lblOutput.Text = "Anunt Incarcat";
System.Transfer("anunt.aspx");

}

else
{
lblOutput.Text = "Campuri obligatorii libere";
}


}

}


 
ok .. where is the code used to save the data?.. you said there is a linkbutton you click that saves the data.. then you try to redirect.. I am confused
 
Jbenson001, the code for insert is the defaut code made by objectdatasource.
Ca8msm i was refering to Server.Transfer, sorry about that.
 
My understanding of your original post was that you wanted to Insert, Update or Delete from a FormView, then after that is complete, redirect to another page, is that correct?

If so, why do you have a button to redirect or transfer?

If my understanding is correct, then you need to place the redirect or transfer in these events of the FormView:
ItemDeleted
ItemInserted
ItemUpdated
 
thx for the help, works perfect. sorry for the confusion i made with the code and rest. Thx again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top