473,671 Members | 2,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB .NET DataGrid retaining data from prior use.

1 New Member
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 2231
Motoma
3,237 Recognized Expert Specialist
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 New Member
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.Cle ar()
Apr 26 '07 #3
radcaesar
759 Recognized Expert Contributor
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 New Member
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
5924
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 manually resize a column width with the mouse (not very elegant). Anyone have any ideas how I could enable the datagrid scroll bars in my code? Thanks,
1
2336
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 data set x + x .. and y + y ... Is there a way to reset the datagrid? Current config: Private ds As DataSet = New DataSet
0
1839
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 the select, gets schema from the datareader, creates a table that can host data of that type, fills it with data from the datareader and then binds it to a DataGrid. The problem is that although i seem to do everything correctly and although all...
3
1793
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 information to another object which forms an SQL query and makes the query to the DB (actually to a DBFacade object). In any case, please see the code I have listed below for my update DataGrid event. With this code, the DB is updated using the old...
3
1797
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 when the user saves the data I can use the data already in the datagrid. Typically the user will add several rows before the DataSet.HasChanges is called and the DataAdapter.Update(AllChanges) is called. I want to add an employee number to each...
0
1604
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 for incoming file and create. This sets the file date and time to the system date/time when file is actually transferred rather than retaining the date and time of the file as it sits on the FTP server.
9
2715
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 code: <script runat="server"> Dim sqlConn As New SqlConnection(".....") Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) If Not (Page.IsPostBack) Then FillDataGrid()
2
1846
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 table with pagination form data's are retaining if i select from first page but data not retaining if i select option from other than 1st page. i m using hidden field in pagination page. Thanks stalin
3
1257
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 my_service.Statement Dim my_data As New my_service.my_data
0
8471
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, 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...
1
8593
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
8663
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
7423
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
6218
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
4396
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2804
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
2
2046
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1799
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.