473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

code organization

J
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?
Jan 14 '08 #1
1 951
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
JI'm using codebehind in ASP.Net.
J>
Jpublic partial class edit : System.Web.UI.Page
J{
Jprotected void Page_Load(object sender, EventArgs e)
J{
J// populate the dataset, etc.
JtxtFirstName.Text =
JdsContact.Tables["Contact"].Rows[0]["FName"].ToString();
JtxtLastName.Text =
JdsContact.Tables["Contact"].Rows[0]["LName"].ToString();
J}
Jprotected void btnSave_Click(object sender, EventArgs e)
J{
J// I would like to do something like this
JdsContact.Tables["Contact"].Rows[0]["FName"] =
JtxtFirstName.Text;
JdsContact.Tables["Contact"].Rows[0]["LName"] =
JtxtLastName.Text;
J}
J}
J>
JIn Page_Load, a few dataset's are populated and the page is updated
Jwith the results of the datasets. When the Save button is clicked,
JI want to use the same datasets to update the tables in the db.
JWhat's the best way to make these datasets (like dsContact in the
Jcode)
Jvisible to both Page_Load and btnSave_Click?
Jan 14 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Amardeep Verma | last post by:
Hi, I would like to determine the Country and Organization from a given IP. I have to write a JSP, which when given the IP address gives the country and the organization to which the IP belongs....
5
by: Jo Vermeulen | last post by:
Hello, I was wondering if Java supports a feature of C# (or .NET in general), namely compiling code at runtime. This is nice for scripting purposes. Users can script the application in real...
45
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes...
1
by: John F | last post by:
Currently I'm working on a C# app for a large organization (700 users nationwide). This App is still under development. I have setup code in my App to pull C# source code from a database and...
7
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
1
by: J | last post by:
I'm early in my C# larval stage, so I'd like a little direction to help understand good code organization. Take for example a program I have written in another language that does the following: ...
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
35
by: Michel Sanner | last post by:
Hello, One of the greatest feature of Python in my opinion is the way the interpreter can be used to integrate a wide variety of software packages by dynamically linking them. This approach has...
2
by: Bart Van der Donck | last post by:
Hello, I'm posting the software for one-FAQ-a-day as described on http://tinyurl.com/qcxw7 (comp.lang.javascript, July 18 2006, titled "CLJ newsgroup FAQ) and on http://tinyurl.com/ppt2s...
6
by: Jeff Gardner | last post by:
Greetings: I am attempting to get conditional output based on POSTed form data. If the posted value is either the key or value of an array, $x=key and $q=foo. elseif it is neither key nor...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.