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

Datatable and Grid

i have created a datatable and bind it to my datagrid1 to

how can i delete rows by content

for exampl
i have 3 column test1 test2 test3 with a number of rows, lets say 5
in one of these cells of column TEST2 there is a value of "BET" in it
How can i find it and delete that row

Thanks
Nov 16 '05 #1
3 3001
Create a DataView and Bind the grid to it (I'm assuming you want to do this
programatically, not just filter it so only BET shows and the user then
deletes it via the ui)

Ok, so you have a datatable dt
DataView dv = dt.DefaultView;
DataGrid1.DataSource = dt;
Ok, so no we have the thing bound to the view instead of the datatable.
Object[] searchValue = new Object[1];
dv.Sort = "Test2";
searchValue[0] = "BET";
int i = dv.Find(searchValue);
dt.Rows[i].Delete();

If you want more values to find, then just change the size of the arrray and
then add the additional values.

Now, if you wanted to just show the Row(s) with BET, in the grid, you could
just set the RowFilter.. dv.RowFilter = "Test2 = BET" ; and then the grid
would now only show the Row or rows with BET in Test2.

Does this help?
"NewBie" <an*******@discussions.microsoft.com> wrote in message
news:CC**********************************@microsof t.com...
i have created a datatable and bind it to my datagrid1 to .

how can i delete rows by content.

for example
i have 3 column test1 test2 test3 with a number of rows, lets say 5.
in one of these cells of column TEST2 there is a value of "BET" in it .
How can i find it and delete that row?

Thanks

Nov 16 '05 #2
Sorry one last issue . what if the value i want to find is a number ?
Nov 16 '05 #3
I was able to delete the rows , but the issue now is after deleting a row or many the program stops responding. Sometime i get an error System.IndexOutOfRangeException: There is no row at position -1

DataView dv = orderTable.DefaultView
Object[] searchValue = new Object[1]
dv.Sort = "ID"
string test = (oStat.RemoteOID.ToString ())
searchValue[0]=(test)
int i = dv.Find(searchValue)
orderTable.Rows[i].Delete()

Any sugestion
Thank You
Nov 16 '05 #4

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

Similar topics

3
by: clyyy2002 | last post by:
At added two column and more column hereafter,I immediately click del button,the program is no problem. but if i first click the DataGrid columnHeader and then click the del button, i find when...
9
by: VMI | last post by:
We have this huge application that's based on storing tons of data on a dataTable. The only problem we're having is that storing LOTS of data (1 million records) into a datatable will slow down the...
3
by: tomi | last post by:
Hi I have following problem. I have a datatable filled with some data. Each row holds its ID (column named "Row_ID") DataTable dtTable; I have a datagrid to which I assign this datatable....
1
by: Mike | last post by:
I have an ASP.NET/VB app that updates values in a DataTable over the course of about 3 different pages. On the way out of the first of these pages, I explicitly build the DataTable from values in...
2
by: Kenneth | last post by:
Hi, I want to make sure I got the easiest way on how to bind a grid's datasource to a datatable. I've made an in-memory datatable Dim dtTotal As DataTable Dim drow As DataRow dtTotal = New...
1
by: cindy | last post by:
Get data into datatable, add to dataset dsSearch " Get data into datatable, add to dataset dsSearch Using In-Memory SQL Engine join the tables and select the filenames from the join, add to...
10
by: JohnR | last post by:
I have a datatable as the datasource to a datagrid. The datagrid has a datagridtablestyle defined. I use the datagridtablestyle to change the order of the columns (so they can be different than...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
11
by: inpuarg | last post by:
I have 2 datatables. They are identical. I want to compare them by cell's content. They are all same. But dt1 == dt2 or dt1.GetHashCode() == dt2.GetHashCode() doesn 't work. There are big...
5
by: =?Utf-8?B?S3VuYWwgUGF0ZWw=?= | last post by:
I have a DataTable with Column DataType as Double I just want to show data in C# datagrid with two decimal places which property do I set for DataColum of DataTable and How? Thanks
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...

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.