473,473 Members | 1,571 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

A Strange Issue with DataGrid

Hello,

I am trying to bind a DataTable to a Grid which will allow users to
Edit data and then submit the changes back to the Database. I want to
display values in the Grid satisfying a particular criteria like
follows:

Dim tbl as new DataTable
For Each row As DataRow In DataTableName.Rows
If (row.Item("ColumnName") Is System.DBNull.Value) Then
tbl.Rows.Add(row.ItemArray)
End If
Next

Grid.DataSource = tbl

But on the other hand I have created and Filled the DataTableName
dataTable as follows:

DataAdapter.Fill(DataTableName)

After the user has done changes on the Grid (e.g. Deleted few rows,
modifies few column values or added few rows), I want to Update the
Table and I issue the following command for that:

DataAdapter.Update(tbl)

Which gives me a problem that the Rows are not properly updated rather
multiple records are added for nothing and many other problems are
seen in the original table.

Also I cannot Update using the following:

DataAdapter.Update(DataTableName)

because I didn't bind the DataTableName DataTable to the Grid because
I only want to display records in the Grid satisfying certain
criteria.

Has anyone any idea how to make it work or modify my logic.

cheers
Nov 20 '05 #1
1 1011
Cor
Hi Sajid,

Your have in my opinion defintily have to look first to the dataview (very
easy to handle in combination with a datagrid) and the SQL or OleDb
commandbuilder.

Know also that deleting rows from the datagrid using the "del" key on the
keyboard will delete the row but also the information that it is deleted and
therefore never update the database.

Do also not forget to do before the update the currencymanager
endcurrentedit methode

I hope this helps for a start?

Cor
Nov 20 '05 #2

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

Similar topics

0
by: elime | last post by:
Hi all I have a strange behaving on some PC with my DataGrid. It only occurs on some PC, on others it works perfectly fine. ->(same ..net version installed) it's very confusing. starting...
2
by: michele | last post by:
Hi, i'm using a datagrid control in my webform, with AutoGenerateColumns=false; it work very well if EnableViewState=true; including paging and sorting, but this cause a big performance issue, so...
1
by: Kepler | last post by:
I'm fighting a really strange bug that involves both a DataGrid and a Repeater disappearing on postback. The strange thing is that I've distilled the problem down to a simple program, that...
2
by: sosh | last post by:
Hi, I'm having a strange problem with the update function of a datagrid: I have a datagrid, the first column lists item names from a database. Second column is an EditCommandColumn, and then I...
4
by: jibran | last post by:
Hello. I have wrapped the DataGrid control with my own class (SmartDataGrid) adding some necessary functionality. My current webform has 2 SmartDataGrids. The first is populated by selected...
1
by: Sajid | last post by:
Hello, I am trying to bind a DataTable to a Grid which will allow users to Edit data and then submit the changes back to the Database. I want to display values in the Grid satisfying a...
1
by: Chris | last post by:
Hey, I have a DataGrid that allows for a combobox in a column through a inherited DataGridColumnStyle and a inherited ComboBox. I have 3 of these columns in a row. The overall problem is that...
1
by: Lurc | last post by:
Hi all, One field of Access table is date/time type, and format is long time. In VB.NET, as this table linked to a datagrid, a strange date 12-30-1899 is shown instead of the time expected....
2
by: Antonio | last post by:
Good morning, everyone. Here is the strange behavior: I have a datagrid (dgPIs) with paging enabled. When I click to view any page in the grid, it runs the private void lnkIPReg method,...
1
by: chris3vic | last post by:
I have a dynamically created datagrid, populated from a dataset that is filled by a sql string triggered by a command button. The application itself allows a user to input a selection of criteria and...
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
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
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...
1
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
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.