PC Review


Reply
Thread Tools Rate Thread

code organization

 
 
J
Guest
Posts: n/a
 
      14th Jan 2008
I'm using codebehind in ASP.Net.

public partial class edit : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// populate the dataset, etc.
txtFirstName.Text =
dsContact.Tables["Contact"].Rows[0]["FName"].ToString();
txtLastName.Text =
dsContact.Tables["Contact"].Rows[0]["LName"].ToString();
}

protected void btnSave_Click(object sender, EventArgs e)
{
// I would like to do something like this
dsContact.Tables["Contact"].Rows[0]["FName"] = txtFirstName.Text;
dsContact.Tables["Contact"].Rows[0]["LName"] = txtLastName.Text;
}

}

In Page_Load, a few dataset's are populated and the page is updated
with the results of the datasets. When the Save button is clicked,
I want to use the same datasets to update the tables in the db.
What's the best way to make these datasets (like dsContact in the code)
visible to both Page_Load and btnSave_Click?


 
Reply With Quote
 
 
 
 
Michael Nemtsev [MVP]
Guest
Posts: n/a
 
      14th Jan 2008
Hello J,

declare the valiable as class field and store dataTable in cache

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


J> I'm using codebehind in ASP.Net.
J>
J> public partial class edit : System.Web.UI.Page
J> {
J> protected void Page_Load(object sender, EventArgs e)
J> {
J> // populate the dataset, etc.
J> txtFirstName.Text =
J> dsContact.Tables["Contact"].Rows[0]["FName"].ToString();
J> txtLastName.Text =
J> dsContact.Tables["Contact"].Rows[0]["LName"].ToString();
J> }
J> protected void btnSave_Click(object sender, EventArgs e)
J> {
J> // I would like to do something like this
J> dsContact.Tables["Contact"].Rows[0]["FName"] =
J> txtFirstName.Text;
J> dsContact.Tables["Contact"].Rows[0]["LName"] =
J> txtLastName.Text;
J> }
J> }
J>
J> In Page_Load, a few dataset's are populated and the page is updated
J> with the results of the datasets. When the Save button is clicked,
J> I want to use the same datasets to update the tables in the db.
J> What's the best way to make these datasets (like dsContact in the
J> code)
J> visible to both Page_Load and btnSave_Click?


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code Organization ... Really need advice shapper Microsoft ASP .NET 0 9th Sep 2008 06:17 PM
Code Organization ... Really need advice shapper Microsoft C# .NET 1 9th Sep 2008 06:01 PM
code organization J Microsoft C# .NET 1 14th Jan 2008 08:20 PM
code organization =?Utf-8?B?YWxla20=?= Microsoft Access VBA Modules 1 6th Oct 2005 09:20 AM
good code organization J Microsoft C# .NET 1 5th Nov 2004 01:43 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:17 AM.