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

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 1008
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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
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...

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.