473,651 Members | 2,659 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remember values textboxes in datagrid

Hello,

I've got a datagrid with a textbox in each cell. I've also two buttons, one
to add a row to the datagrid and one to delete a row. A user can type data
into textboxes and then submit it to a database (by clicking on a submit
button).
The problem is that every time, the "add row" or "delete row" button is
clicked, the textbox values in the datagird are emptied, because when the
page postbacks it gets the latest datatable from a session variable. Because
a new datatable is only saved when a new row is added or deleted it will
have no values every time. Do you have any ideas how to remember the values
from the textboxes? Thanks in advance for responding.

Regards,
Arjen
Nov 19 '05 #1
1 1385
When populating your DataGrid (i assume in the page_load), ensure to wrap
this with the if(!Page.IsPost Back) statement

so

Page_Load(objec t s, eventargs e)
{
if(!Page.IsPost Back)
BindGRidFromSes sion();
}
This should prevent the datagrid from repopulating

Then once you have added or deleted a row, call this method afterwards

dgDeleteRow()
{
//do deleting
//Reset session - if needed
BindGridFromSes sion();
}

HTH
"Arjen Hoekstra" <a.**********@G EENSPAMstudent. utwente.nl> wrote in message
news:dd******** **@netlx020.civ .utwente.nl...
Hello,

I've got a datagrid with a textbox in each cell. I've also two buttons,
one to add a row to the datagrid and one to delete a row. A user can type
data into textboxes and then submit it to a database (by clicking on a
submit button).
The problem is that every time, the "add row" or "delete row" button is
clicked, the textbox values in the datagird are emptied, because when the
page postbacks it gets the latest datatable from a session variable.
Because a new datatable is only saved when a new row is added or deleted
it will have no values every time. Do you have any ideas how to remember
the values from the textboxes? Thanks in advance for responding.

Regards,
Arjen

Nov 19 '05 #2

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

Similar topics

0
1987
by: Gamze | last post by:
Hi, How can i get values from datagrid to combobox and should select the same name as in datagrid row on the combobox control In my vb.net windows application ,i have combobox which is populated by sqlserver database table.When i select value from combobox ,value saved in to other table of my database and i use to datagrid to show this table.
6
1458
by: Tim Whelan via DotNetMonster.com | last post by:
Hi I am developing an asp.net web application using c# and having trouble trying to display integer values, that I have taken from the database, correctly on my webform textboxes. The values are consistently displayed with four 0?s after the decimal point and I am just wondering if anyone knows how to prevent this from happening. Thanks in advance. Tadhg88 -- Message posted via http://www.dotnetmonster.com
0
1528
by: Ozer | last post by:
Hi guys, I need some help. In my datagrid's updatecommand event i'm trying to get textboxes values and also do it. But when i update the values in textboxes and fire the event, I can't get the updated values. Please help me. Thanks for any help. Bye. Ozer And here's my code: Imports System Imports System.Data Imports System.Data.OleDb
12
2629
by: Mike | last post by:
I'm calling a component to get my data. The component is returning a dataset. I need to populate text boxes on my aspx page with the data within the datalist. Where can I find an example that does this? Here is the code i'm using and i'm gettting an error: code: Try dbConn.GetCarInformation(CarID)
7
2189
by: Aaron | last post by:
Complete code follows. I am new to .NET programming (and programming in general) and I am having a difficult time understanding how to fill a variable in one sub, and then access it from another. I have tried declaring them as shared, public, friend, etc and I always get an error stating that something is not valid on a local variable declaration. For example, in the following code for Sub DataGrid_Select, I have CurrentID and...
8
2255
by: stephen | last post by:
Hi, I make use of properties to store values that are relevant to the page but this time I am posting the page to itself and the values are Zero or null (they disappear). is there any other way I can store them/preserve them so that when I post back I can use the values. I tried session and it works but some other ideas would be helpful. Appreciate your help, Stephen
0
874
by: hussainiyad | last post by:
hi to all this is hussain i need ur help. in a datagrid there r two textboxes and a button and a label, if i type any value in that textboxes and click the button if the values r equal then the msg "The values r equal " will appear in the label if the values r not equal the msg"the values r not equal " may appear in the label. but it,s all may happen runtime without database connection, can it possible
1
2026
by: RN1 | last post by:
I have a DataGrid with 7 BoundColumns. A user can login as an admin or non-admin. When a user logs in as a non-admin & the DatGrid is in the editable mode, I want only the first 4 columns i.e. the TextBoxes in the first 4 columns to be editable & the remaining 3 TextBoxes should remain disabled. This is what I tried (in the OnItemDataBound event functions): -------------------- If (sessAdmin = 0) Then For i = 4 To 6
1
2769
by: mzahid | last post by:
Hellow All I am new in ASP.Net Application. I have a page with some TextBoxes and GridView. I have Done the Values of Textboxes save into Invoice Table and i want to save Invoice Detail values through DataGridView, But the DataGridView behave readonly. In Windows Application form i can write in DataGridView (As many Record) and click save Botton then textboxes value save in Invoice table & DataGrid Values save in Invoice Detail Table. using...
0
8792
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8694
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8457
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,...
0
8571
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 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...
0
7294
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6157
isladogs
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...
0
4143
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...
1
1905
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1585
bsmnconsultancy
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...

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.