473,403 Members | 2,338 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,403 software developers and data experts.

VB .NET DataGrid retaining data from prior use.

1
I am using VB .NET (2003) for a project that includes a datagrid on one form that allows the user to switch to details on a second form. The datagrid was built in design mode with all the proper style information.
The user types in a part of a company name and a database search returns matching data (via ADO) to a dataset. If more than 1 matching company was found, the datagrid is made visible and has its source and member assigned to the table in the dataset. All appears fine. The user clicks on one item in the grid and the program senses the item, locates the company in the database, retrieves detailed data and displays on the secondary form. The user can then return to the first form and select a different item on the grid to follow a path.
If the user does not want anything in the current grid, they START OVER and enter a new search string. My program retrieves new data into the DataSet however the grid appears to "remember" items that were selected during a prior use. Their retained text values appear in the new grid in place of data in the actual underlying dataset.

How do I tell the data grid to forget it was ever used before and start fresh with no current cell or remembered selections?
Apr 6 '07 #1
4 2222
Motoma
3,237 Expert 2GB
Reassign the datagrid using the New identifier.


I am using VB .NET (2003) for a project that includes a datagrid on one form that allows the user to switch to details on a second form. The datagrid was built in design mode with all the proper style information.
The user types in a part of a company name and a database search returns matching data (via ADO) to a dataset. If more than 1 matching company was found, the datagrid is made visible and has its source and member assigned to the table in the dataset. All appears fine. The user clicks on one item in the grid and the program senses the item, locates the company in the database, retrieves detailed data and displays on the secondary form. The user can then return to the first form and select a different item on the grid to follow a path.
If the user does not want anything in the current grid, they START OVER and enter a new search string. My program retrieves new data into the DataSet however the grid appears to "remember" items that were selected during a prior use. Their retained text values appear in the new grid in place of data in the actual underlying dataset.

How do I tell the data grid to forget it was ever used before and start fresh with no current cell or remembered selections?
Apr 6 '07 #2
svac
1
clear the dataset every time when a new search is made.
That is in the click event after your dataset initialization
put the code
YourDataSet.Clear()
Apr 26 '07 #3
radcaesar
759 Expert 512MB
After your first transaction for the click is over, Dispose the Dataset and DataAdapter. Next time create a new one and use that.

:)
Apr 26 '07 #4
brunko
1
I am disposing the dataset and the dataadapter and the highlighted items still carry over to the new data.
May 29 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Bill Sonia | last post by:
It seems whenever I set a DataGrid.DataSource = DataTable (vb.net) to populate a datagrid, the scroll bars on the datagrid default to disabled. And the only way I can get them to enable is to...
1
by: Schlauberger | last post by:
I have a form that has a Datagrid, there is a menu option that I use to toggle the Datagrid between two different data sources (x and y). As I continue to toggle the datagrid is duplication each...
0
by: Bill Toulias | last post by:
I want to be able to display the tuples of a select query (which may change at runtime, so no prior knowledge for column characteristics) and edit them as well. I used this code, that executes...
3
by: Jon Agiato | last post by:
Hi, I am trying to use a data grid in a web application in which I have three tiers. The DataGrid is not set up to a data source, or a data adapter, so everytime I make a change I send the cell...
3
by: Jim | last post by:
I have a datagrid with a DataAdapter as the DataSource. The user fills in their data for 3 columns and I want to programically add a value to the 4th (invisible) column (employee number). That way...
0
by: Thomas Homan | last post by:
Hello, Is there a method in the FtpWebRequest that allows for preservation of the file being transferred original date and time in vs2005 vb? In the FTPSample the method is to set up stream...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
2
by: s4lin | last post by:
problem is pagination not retaining data field i have form with general data field, and i need to select some option which is store in database, so i open another page with retrieving data from...
3
by: David | last post by:
Hi all, This is a weird one. I have been asked to look at an intermittent fault. Basically, I have a webservice that is delivering info into a datagrid. Dim Statement As New...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...

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.