473,394 Members | 1,742 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,394 software developers and data experts.

VB.Net Datagrid Reset

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
Private da As OleDb.OleDb.DataAdapter
Private conn as OleDb.OleDb.Connection
Private member as string
Private bolReset as boolean

Private Sub mnuViewSwitch_Click(....)

If bolReset = True then
bolReset = False
Else
bolReset = True
End if

bolError = Load_Grid(bolReset)

End Sub

Private Function Load_Grid(bolDefault as boolean)as boolean

if bolDefault = True then
strSQL = "SELECT ..."

da = New OleDb.OleDbDataAdapter(strSQL,conn)

member = "tblName"

da.Fill(ds, member)

objDataGrid.DataSource = ds.DefaultViewManager
objDataGrid.SetBindings(ds, member)

Else
'code is repeated for different strSQL

Any assistance would be greatly appreciated, Thanks.

Jul 21 '05 #1
1 2312
The simple solutions are always right before our noses:

ds.Clear()

inserted prior to filling the DataAdapter (da) will prevent new data from
being duplicated.

"Schlauberger" wrote:
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
Private da As OleDb.OleDb.DataAdapter
Private conn as OleDb.OleDb.Connection
Private member as string
Private bolReset as boolean

Private Sub mnuViewSwitch_Click(....)

If bolReset = True then
bolReset = False
Else
bolReset = True
End if

bolError = Load_Grid(bolReset)

End Sub

Private Function Load_Grid(bolDefault as boolean)as boolean

if bolDefault = True then
strSQL = "SELECT ..."

da = New OleDb.OleDbDataAdapter(strSQL,conn)

member = "tblName"

da.Fill(ds, member)

objDataGrid.DataSource = ds.DefaultViewManager
objDataGrid.SetBindings(ds, member)

Else
'code is repeated for different strSQL

Any assistance would be greatly appreciated, Thanks.

Jul 21 '05 #2

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

Similar topics

4
by: Job Lot | last post by:
On form load my datagrid gets populated with values from database table. How can I reset values in my DataGrid to 0 on click of a button? thanks
5
by: Mojtaba Faridzad | last post by:
Hi, with SetDataBinding( ) a DataGrid shows a DataView. user can select some rows in the grid by holding cotrol key. when user clicks on Delete button, I should delete all selected rows. I am...
1
by: ppn | last post by:
BlankHi, I have two datagrids on the form. When I click on the row in the first DataGrids, I want to reset the second datagrid before binding the dataset with new sql statement. I tried with...
5
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. ...
1
by: Vaclav Jedlicka | last post by:
Hi I need a datagrid on a page, but it is rendered with the style "border-collapse:collapse;". I do not need this style. It interferes with the settings in my CSS file. I tried to supress it...
1
by: Harry Devine | last post by:
I have a DataGrid that is configured to use the Edit/Update/Cancel concept correctly. My grid shows values from 5 database fields. I only need to update that last 4 fields. The last field is a...
1
by: Lee Price | last post by:
Hi all, I have a bound datagrid which is filled with data and displayed.Now on the click of a button I need to refill the datagrid with new data but the problem is the datagrid mixes up the new...
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.