Hi folks,
Although I'm an experienced programmer, I'm new to ASP and relatively new to web programming, so I hope you'll be patient with my questions.
I'm working on a project using ASP.NET and C# for the server side code. I've written code to retrieve data from a database and put it into a dynamic html table for the user to view and edit. Works great. Now I want to save those changes and that's where I'm unsure how best to proceed.
I have a "Save Changes" button on the page that I want the user to use to indicate that they've finished making changes to the data and to store it back to the database. My initial intention is to have the click of this button call my server side C# code and it will scan the table, find what changed (if possible) and store it. If it can't necessarily tell what changed, that's okay as I can store all records regardless as it's only about 200 records.
First of all, is this really the way to do it? Or is there a smarter way to store changes back to the database?
Assuming my design is adequate, how is my server side code able to get to the records in this table on the client?
Also, I'm thinking of storing a hidden "dirty bit" on the client side for each row that changes (via JavaScript) and the "Save Changes" will scan through the table for those that have the dirty bit set and only save those. Is this feasible? Again, is there a smarter way to handle this?
Thanks for any advice anyone can give. I'm learning a lot about the limitations of web programming and the tricks of having to pass information between client and server. It makes things a bit more challenging, to be sure.
Robert Porter
4 1726
Instead of using an html table I would recommend using a datagrid (or Gridview if you are using .NET 2.0 or higher). This control gives you the ability to identify the row being updated in the ItemCommand event (RowCommand if using GridView).
Nathan
Plater 7,872
Recognized Expert Expert
The GridView generates a dynamic html table for you. You can just give it an instance of the DataTable (or DataSet) object and it will populate for you.
A bonus of using the DataTable is that each row in there has a .RowState property that will tell you if anything has changed (you can then accept or reject changes). Which can be used to writeback data to database.
Thanks for the advice. I'd already spent a lot of time setting up the html table and it works, so I was hoping to avoid having to scrap that and do the GridView which I've just discovered. But the GridView certainly does seem the way to go. I've been experimenting with it (and having a few issues with my database connection, but that's another topic).
Is it possible to add a dynamically populated DropDownList in a GridView? I'd like to get a list of valid values from the database and add it to the GridView's DropDownList so the user has to choose one of those values.
Robert
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Lester Moreno |
last post by:
Hello all,
Up to now C# have been an great experience but I found myself in a end of
the road problem.
Let say that you have two windows program running on a local network area.
User1 and user2 have the same information in the dataset and user1 makes a
change, unless user2 refill all his tables in his dataset he can't see the
|
by: jsale |
last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app
i have made is running on IIS v6 and consists of a number of pages that allow
the user to read information from the database into classes, which are used
throughout the application. I have made class collections which, upon reading
from the DB, create an instance of the class and store the DB values in
there temporarily. My problem is that if user1 looks at...
|
by: |
last post by:
I have an app that retrieves data from an Access database. At the moment I
have the SQL string as a Const in my app. I understand this is not best
practice. I don't want the user to have access to read or modify this string
so I don't want to store it in an INI / Text file or in registery. Can
someone please tell me the best practice for this.
Thanks
Mike
|
by: Jobs |
last post by:
Download the JAVA , .NET and SQL Server interview with answers
Download the JAVA , .NET and SQL Server interview sheet and rate
yourself. This will help you judge yourself are you really worth of
attending interviews. If you own a company best way to judge if the
candidate is worth of it.
http://www.questpond.com/InterviewRatingSheet.zip
|
by: Lucky_Syringe |
last post by:
I wrote this script to display different files from a database and
properly display them by their respective MIME types. I have two
questions: the first is that it just so happens not to work, and I'm
just wondering if there are any discrepancies that I can't see that
maybe someone else can, and the second is what would be the benefits
and the drawbacks of storing different types of files in a database,
for example files like jpeg and gif...
| |
by: shamirza |
last post by:
· When was .NET announced?
Bill Gates delivered a keynote at Forum 2000, held June 22, 2000,
outlining the .NET 'vision'. The July 2000 PDC had a number of sessions
on .NET technology, and delegates were given CDs containing a
pre-release version of the .NET framework/SDK and Visual Studio.NET.
· When was the first version of .NET released?
The final version of the 1.0 SDK and runtime was made publicly
available around 6pm PST on...
|
by: shamirza |
last post by:
· What is view state and use of it?
The current property settings of an ASP.NET page and those of any
ASP.NET server controls contained within the page. ASP.NET can detect
when a form is requested for the first time versus when the form is
posted (sent to the server), which allows you to program accordingly.
· What are user controls and custom controls?
Custom controls:
A control authored by a user or a third-party software vendor that...
|
by: LionsDome |
last post by:
Hello,
I have a vb.net page which a bunch of checkboxes. A user can select a
checkbox(s) and hit the submit button to store those values in a SQL
Server table. This works fine with no problem the first time the user
submits. However when user submits a second time while changing some
of the selected boxes the page only re-submits the previosly selected
checkbox values. It's like its storing it somewhere in the cache or
something. My...
|
by: jehugaleahsa |
last post by:
Hello:
What is the point of using a DataTable in ASP .NET? We are unsure how
you can use them without 1) rebuilding them every postback, or 2)
taking up precious memory. We are not sure how to store a DataTable in
any other way outside of our servers. In doing so, we leave ourselves
open to large memory requirements. Furthermore, most web pages do not
really support multiple changes per transaction. In other words, when
the user submits...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |