Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 27th, 2008, 10:26 AM
Registered User
 
Join Date: May 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Row is null after formview insert??

Hi

My screen has a gridview for Orders, followed by a formview for editing or inserting orders.This is followed by another gridview containing parts used on the order, followed by another formview for inserting new parts after clicking an Add Part button.
The button runs the following code:

protected void buttAddParts_Click(object sender, EventArgs e)
    {
        //Insert Order - Add Parts button

        try
        {
            this.fvSloParts.ChangeMode(FormViewMode.Insert);
            if (this.fvSloParts.Row.RowState == DataControlRowState.Insert)
            {
                if (fvSloParts.Row.RowType == DataControlRowType.DataRow)
                {
                    // Set the sloID field to the same as parent
                    TextBox myText2 = (TextBox)fvSloParts.FindControl("sloIDTextBox1");
                    if (myText2 != null)
                    {
                        TextBox myText3 = (TextBox)fvSingleLineOrders.FindControl("txtSloId" );
                        int number = Convert.ToInt32(myText3.Text);
                        myText2.Text = number.ToString();
                        gvSingleLineOrders.DataSourceID = "SqlSingleLineOrderList";
                        gvSingleLineOrders.DataBind();
                        this.pnlSloParts.Visible = true;
                        this.pnlShowParts.Visible = false;
                    }
                    else
                    {
                        Tools.Log("Cannot find control sloIDTextBox1");
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Tools.Log("buttAddParts_Click", ex);
        }
    }

After adding the part, there is an Insert button that completes the insert:

protected void InsertButton_Click1(object sender, EventArgs e)
    {
        //Insert Orders - Add Parts - Add Part button
        this.pnlSloParts.Visible = false;
        this.pnlShowParts.Visible = true;
        gvSloParts.DataSourceID = "SqlSloParts";
        gvSloParts.DataBind();
        gvSingleLineOrders.DataSourceID = "SqlSingleLineOrderList";
        gvSingleLineOrders.DataBind();
    }

Now, when I go to add another part, it crashes on the line:

if (this.fvSloParts.Row.RowState == DataControlRowState.Insert)

Because Row is null. How do I make it work please?

Stapes


 
Old June 27th, 2008, 10:19 AM
Registered User
 
Join Date: May 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

NOBODY KNOWS THE ANSWER. EITHER THAT OR NO-ONE CAN BE BOTHERED.






Similar Threads
Thread Thread Starter Forum Replies Last Post
fileupload control in formview insert item templat rakuntal General .NET 10 August 8th, 2007 12:55 AM
Confirm Page for insert formview mar0364 BOOK: Beginning ASP.NET 2.0 and Databases 0 February 22nd, 2007 10:34 PM
update/delete fails when row contains null values davej ASP.NET 2.0 Basics 2 December 6th, 2006 03:47 PM
Hide a Row in a FormView Control frosty ASP.NET 2.0 Basics 5 July 14th, 2006 03:07 PM
BULK INSERT NULL(s) nathansevugan SQL Server 2000 2 November 29th, 2005 01:11 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.