Trust me, once you learn how ASP.NET works, you'll wonder how you ever did it 
any other way. :) Not that it doesn't have its limitations, but for the most 
part, it makes a lot things that were tedious in PHP easy to do.

First, we're talking ASP.NET 1.1, right, and not 2.0? Because in 2.0, there are 
specialized classes and controls that encapsulate a lot of your registration 
and profile handling, and I haven't figured out most of it yet.

You can still take a similar approach in ASP.NET. What you'll need are several 
Panels and you control the visiblity of them in your code-behind class. 
However, I would suggest for simplicity's sake, make add person and add branch 
two separate pages. Additionally, .NET encourages an n-tier design where your 
business and data logic are encapsulated in other classes, so you don't do 
everything at the page level, and the page is only responsible for user 
interface.

Here's a sample of what you might have in the page:

private void Page_Load(object sender, EventArgs e)
{
    if (!Page.IsPostBack)
    {
        // first visit
        Page1Panel.Visible = true;
        Page2Panel.Visible = false;
        Page3Panel.Visible = false;
    }
    else
    {
        switch (CurrentPgHidden.Value)
        {
            case "2":
                Page2Panel.Visible = true;
                break;
            case "3":
                Page3Panel.Visible = true;
                break;
        }
    }
}

protected void Page1Submit_Click(object sender, EventArgs e)
{
    if (!Page.IsValid)
        return;

    Member mem = new Member();
    mem.Email = EmailTbx.Text;
    mem.FirstName = FirstNameTbx.Text;
    // etc

    try
    {
        MemberManager.AddNewMember(mem);
        MemberIDHdn.Value = mem.MemberID;
        CurrentPgHdn.Value = "2";

        // success -- go to page 2 of add
        Page1Panel.Visible = false;
        Page2Panel.Visible = true;
    }
    catch (Exception ex)
    {
        ErrorLbl.Text = ex.Message;
    }
}

protected void Page2Submit_Click(object sender, EventArgs e)
{
    int memberID = Convert.ToInt32(MemberIDHdn.Value);
    Member mem = MemberManager.GetMemberById(memberID);

    // process page 2 stuff
}

Then in your business layer class (for simplicity's sake, I'll combine the data 
access layer into the business class, but I prefer to have it as a separate 
class, so I don't have to repeat all the opening of the connections and 
whatnot):

public static void AddNewMember(Member mem)
{
    SqlConnection conn = new SqlConnection();
    conn.ConnectionString = "...";
    conn.Open();

    using (conn)
    using (SqlCommand comm = new SqlCommand())
    {
        comm.Connection = conn;
        string sql = @"INSERT INTO Members (email, fn, ln)
            VALUES (@email, @fn, @ln)";
        comm.CommandText = sql;

        // populate parameters
        SqlParameter pEmail = new SqlParameter("@email", 
            SqlDbType.VarChar, 50, mem.Email);
        comm.Parameters.Add(pEmail);
        // etc

        comm.ExecuteNonQuery();
    }
}

So you can see, you don't need to use DataSets to do simple inserts. They're 
much more useful when you have a ton of data to process.

HTH.

Matthew Macdonald-Wallace <[EMAIL PROTECTED]> wrote :

> OK,
> 
> I'm starting to think that I need a basic primer on data-sets.  I've got
> an excellent knowledge of how to do all of this in PHP, I just don't
> understand how to do it in ASP.net and C#.
> 
> My usual approach to a task like this would be to create a form where
> you insert the persons name, email address (doubling up as a user name)
> and password into the database on page one of the "Registration Wizard".
> Page one would also retrieve the persons ID from the database and place
> it into a session variable.
> 
> Page two would retrieve the session variable and insert Postal Address,
> phone/fax etc into a different table, setting the personId field in that
> table to the value of the session variable.
> 
> Now here's the trick I usually use.  My add.php usually consists of all
> of the possible options inside nested switch statements for example
> 
> $type = $_GET['t'];
> $pgNum = $_GET['pgNum'];
> $pId = $_SESSION['pid'];
> 
> switch ($type){
> 
>       case "per":
>       
>               switch($pgNum){
> 
>                       case "1":
>                       display Page one information
>                       break;                  
>               
>                       case "2":
>                       display page 2 info
>                       break;
> 
>                       case ...
> 
>               }
>       
>       case "branch":
>       
>       // display page 1 - x of the add branch code
> 
>       break;
> 
> }
> 
> and all the HTML code for the forms would be generated in this way too,
> by the page.
> 
> I can't find a way to do this in ASP.net, and if it is not do-able, that
> is a major failing IMHO.
> 
> I am also having issues with Data Objects.  I just don't understand it. 
> If I want to insert data into a database, I seem to have to create a
> DataSet, add data to it, then save it to the database.  Why can't I
> just execute a straight SQL INSERT statement from the code?[1]  It would
> save memory on run-time (this application is expected to have a huge
> amount of use) and safe on file size too.
::::::::::::::::::::::::::::::
Howard Cheng
http://www.howcheng.com/
Wise-cracking quote goes here.





____ • The WDVL Discussion List from WDVL.COM • ____
To Join wdvltalk, Send An Email To: mailto:[EMAIL PROTECTED] or
use the web interface http://e-newsletters.internet.com/discussionlists.html/
       Send Your Posts To: [email protected]
To change subscription settings, add a password or view the web interface:
http://intm-dl.sparklist.com/read/?forum=wdvltalk

________________  http://www.wdvl.com  _______________________

You are currently subscribed to wdvltalk as: [email protected]
To unsubscribe send a blank email to [EMAIL PROTECTED]
To unsubscribe via postal mail, please contact us at:
Jupitermedia Corp.
Attn: Discussion List Management
475 Park Avenue South
New York, NY 10016

Please include the email address which you have been contacted with.

Reply via email to