Formview inside Wizard which is inside FormView


I have a FormView which contains a Wizard which contains some databinding controls in its steps like Gridview,FormView,...and their ObjectDataSource controls

I want these controls to perform their insert,update methods only when the Wizard finish button is clicked.Is this possible? 

About putting the whole wizard inside a FormView I did this to be able to use Bind+Eval but it is the first time Iam using the wizard control.

11/9/2008 2:04:23 PM 72751 articles. 3 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 47
Get it on Google Play
Get it on Apple App Store

Hi TheEagle ,

Try something like this :


    protected void Page_Load(object sender, EventArgs e)

        if (!Page.IsPostBack)
            this.Wizard1.ActiveStepIndex = 0;
            DataSet ds = retrievedata();
            this.GridView1.DataSource = ds;


    protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
        SelectSqlRows((DataSet)Session["ds"], @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database2.mdf;Integrated Security=True;User Instance=True", "select * from country", "country");

    public DataSet retrievedata()
        DataSet res = new DataSet();
        if (Session["ds"] == null)
            string constr = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database2.mdf;Integrated Security=True;User Instance=True";
            SqlConnection con = new SqlConnection(constr);

            SqlDataAdapter sda = new SqlDataAdapter("select * from country", con);
            sda.Fill(res, "country");
            DataColumn[] primarykey = { res.Tables[0].Columns["countryid"] };
            res.Tables[0].PrimaryKey = primarykey;
            Session["ds"] = res;
            res = Session["ds"] as DataSet;

        return res;

    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        this.GridView1.EditIndex = e.NewEditIndex;
        this.GridView1.DataSource = retrievedata();
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        Label id = this.GridView1.Rows[e.RowIndex].FindControl("Label1") as Label;
        TextBox name = this.GridView1.Rows[e.RowIndex].FindControl("TextBox1") as TextBox;

        DataSet ds = Session["ds"] as DataSet;

        DataRow dr = ds.Tables[0].Rows.Find(id.Text);

        dr["countryname"] = name.Text;

        Session["ds"] = ds;

        this.GridView1.DataSource = retrievedata();
        this.GridView1.EditIndex = -1;


    public void SelectSqlRows(DataSet target, string connectionString, string queryString, string tableName)
        using (SqlConnection connection = new SqlConnection(connectionString))
            SqlDataAdapter adapter = new SqlDataAdapter();
            adapter.SelectCommand = new SqlCommand(queryString, connection);
            SqlCommandBuilder builder = new SqlCommandBuilder(adapter);


            //code to modify data in DataSet here


            //Without the SqlCommandBuilder this line would fail
            adapter.Update(target, tableName);

    <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" OnFinishButtonClick="Wizard1_FinishButtonClick">
                <asp:WizardStep runat="server" Title="Step 1">
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="countryid"
            Width="339px" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating">
                <asp:CommandField ShowEditButton="True" />
                <asp:TemplateField HeaderText="countryid" SortExpression="countryid">
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("countryid") %>'></asp:Label>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("countryid") %>'></asp:Label>
                <asp:TemplateField HeaderText="countryname" SortExpression="countryname">
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("countryname") %>'></asp:TextBox>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("countryname") %>'></asp:Label>
                <asp:WizardStep runat="server" Title="Step 2">



Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
11/14/2008 9:37:39 AM

Similar Artilces:

Controls inside formview inside formview
Hello, I'm trying to insert data into a label that is located in a formview which is located in a formview.  This is what I got so far: Private Sub Test()    Dim fvSecondView As New FormView    fvSecondView = Me.FormView1.FindControl("SecondView")    Dim lblData As New Label    lblData = fvSecondView.FindControl("DataLabel")    lblData.Text = "Some Data" End Sub Now this does work to get data out if I change the last line to: testlabel.text = lblData.Text But just can't seem to get the data to go ...

Formview inside a formview controller
Hi all, I'm using a formview(say formview1) controller to insert a records to a table. I take a value from a dropdownlist which i have placed in  the InsertItemTemplete of the formview1. Lets say the dropdownlist has list of towns and I need to add a new town to the list while the user is in the insert template. To do this I have added another formview (say formview2) to inser a new record to the towns table. My problem is my dropdown list is not getting updated just after I have added a new town. But if I start insert operation all over again then I can see the new town. I know t...

How do I control parameter a control that is inside a formview that has another formview in it?
I have a formview2 within another formview1 but I want to control parameter from a sqlDataSource3 outside the formview a control that is in formview2<asp:SqlDataSource ID="SqlDataSource1" SelectCommand='SELECT "USER,UID" FROM "TUSERS"'><asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1">    <ItemTemplate>        <asp:Label ID="Label1" runat="server" Text='<%# Bind("USER") %>'></asp:La...

SqlDataSource with FormView: Referencing a control inside FormView as control parameter?
I have been looking at this website and was wondering...what if my FormView control had a textbox or label inside of it in its EditTemplate item...can I link my SqlDataSource object (which is also bound to the FormView control) to that control meaning specify control parameter as the textbox which is inside the FormView...? PS: I use vbexpress 2005 programming blog Hi:   You can try something like: <asp:ControlParameter ControlID="FromView1$DropDownList1"   But please make sure the DropDownList (or any other controls) be available all the time. In anoth...

Referencing Nested FormView Control inside the EmptyDataTemplate of a FormView Control
Hi all,I am very new to ASP.Net and have been working on a particularly frustrating problem now for days and cant seem to find an answer to it. I am building a front end to a newly created database and have set 2 session variables that I am using to set default values using the FindControl Method. this works fine until I need to set default values in a nested control. IE...I have a form view control and in that controls EmptyDataTemplate I have another form view control with about 10 fields using the same datasource as the parent form view. I need to place default values in 2 of those fields...

Formview inside a formview
Please help me,this is the situation, i have a formview inside a formview lets name the two as "form-in" as the formview inside the formview and "form-out" as the formview which is holding a formview inside. i hope you get what i mean, so this is how it should work, form-in will have its own query, specifically, display an info from the database, also form-in is in readonly mode, then form-out has also its own query, specifically, it should insert the information that from-in has displayed and some additional textboxes in the database,btw, form-in retrieves its info ...

Wizard Inside Of FormView Control
Hi Everyone ...Maybe I'm doing this the wrong way, but I have placed a Wizard inside of a FormView control on my web page so that I can bind controls on the Wizard to an ObjectDataSource.Everything works fine, but I need to gain access to the Wizard Events so that I can override some functionality.  Since the Wizard is inside of the FormView control, it does not display on the list of the controls with events in the VB source editor.  What do I name the subs/functions that I'm creating so that they are found by the Wizard when the Next or Previous buttons are selected by th...

Problem in Formview inside Formview(Nested Formview )
I am using a nested formview and in child formview i have a literal control and image control. I need to assign values to the literal and image control in my code if sqldatasource is not returning any row. I am unable to find a literal and image control getting a error as "Object reference not set to an instance of an object"The aspx is as :<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource3" DataKeyNames="country_code" EnableViewState="False" OnDataBound="FormView1_Databound"><ItemTemplate>...

Finding a controls inside a FormView which is inside a MasterPage
Hi, I have few controls (textboxes) inside a FormView that is inside a MasterPage. The findcontrol doesn't work for me or I'm not doing it right. If I JUST use the FormView or JUST the MasterPage then the findcontrol works. For example TextBox idTextBox = (TextBox)FormView1.FindControl("TextBox1"); works if I don't use the MasterPage. Can someone please help? How do you find a control inside the FormView1 that is inside the MasterPage? Any help would be appreciated. Hi, friend:   Try this:         FormViewRow fr = ((FormView)Master.FindCont...

SOS:How to find control inside the sub FormView of main FormView? 2.0 Greetings to all, I have a sub FormView inside a main FormView and I've done a lot researh for using FindControl to get the control inside the sub FormView but still can't make it. This is going to kill me......Here is my code: Dim lblLabel As Label lblLabel = CType(FormViewMain.FindControl("FormViewSubID").FindControl("LabelID"), Label) It's return nothing.......any clue? Thanks in Advance. Hi Tenno, In the debugger I tried (C#):((Label)FormView1.FindControl("FormView2").FindControl("Label1")).Textand((Label)((FormView)FormView1.FindControl("FormView2")).FindCon...

Events not firing on custom control inside FormView inside UpdatePanel
Hi all- I have a custom control that I have been using inside a FormView; all its events have been firing properly. Recently I placed the FormView inside an UpdatePanel, and now the events of the control are not firing. I set the AutoPostBack property of the control to True and even turned on AutoEventWireup, but the event doesn't fire.I tried adding the control as a Trigger on the UpdatePanel using this syntax: <asp:AsyncPostBackTrigger ControlID="FormView1:CustomControl1" EventName="SelectionChanged" /> but the event still doesn't fire. Am I doi...

controls not visible inside formview control
I am trying to write a query to select data from one table based on the resultof a drop down list that pulls data from another table. The query I am writing is: "SELECT church.churchName, church.churchId AS Expr1 FROM [churches]WHERE ([deanery.deaneryId] = @churches.deaneryId)"I am using a sql source controlNow I found an example from a website that pulls data from one drop down list and usesthe selected value to populate the second drop down list. But, the controls are not part of a formviewcontrol. So my question is how do I get the dropdownlist control that is located...

Trying to set focus to child control inside FormView EditItemTemplate inside a TabPanel
Hey all I have a long page with a bunch of FormViews that I want to have the user click to the EditItemTemplate and have the focus go to that particular FormView in the aspx page. Or if not the focus at least to have the page scroll to where that control is so the user isn't confused  Here is kind of what I am doing  1 <ajaxToolkit:TabPanel runat="server" ID="Panel1" HeaderText="Account Info"> 2 <ContentTemplate> 3 <asp:FormView ID="fvMyName" runat="server" DataSourceID="sqlGetMemberName" ...

How I can accede to the controls that they find inside a formview from VB.NET
Hi again: How I can accede to the controls that they find inside a formview, to use its values, to modify or validate it, from  VB.NET. For example I have the next page Items.aspx: <table border="0" cellspacing="0" cellpadding="0">     <tr>        <td><asp:TextBox runat="server" ID="MinIDProducto" Text="" /> </td>        <td></td>     </tr>     <tr>        <td><asp:Tex...

Web resources about - Formview inside Wizard which is inside FormView -

Visual Studio 2008 and .NET Framework 3.5 Service Pack 1 Beta
In this article, Scott discusses the recently released beta version of Visual Studio 2008 and .NET Framework 3.5 Service Pack 1. He starts with ...

Visual Studio 11 Beta in Context
... data controls. I blogged about this before in my Elegant Web Forms post . There's two way data-binding in controls like the FormView now instead ...

Visual Studio General Questions Forum
Sign in Home Samples Languages Extensions Documentation Community Forums CodePlex User Voice File a Bug Get started for free Visual Studio Developer ...

Advanced Residential Search

Keep, share, and discover the best of the Web using Delicious, the world's leading social bookmarking service.

ASP.NET Web Forms DynamicData FieldTemplates for DbGeography Spatial Types
... - 10 Tutorials Mixing Razor Views and WebForms Master Pages with ASP.NET MVC DbGeography FieldTemplates for ASP.NET Web Forms Here's a FormView ...

Resources last updated: 1/8/2016 3:46:48 AM