datatable

How can i update DataGridView in c# if Source has changes

Hi, i have a Problem with DataGridView in c# and i hope you can help me :) I added a DataGridView to my Application and bind it to DataTable. The DataTable changing the content but the DataGridView doesnt display it... How can i change this ? Thanks ...

DataTable Clone

Hi, ds = (DataSet)Session["Details"]; DataTable dt = ds.Tables[0]; DataTable temp = dt.Clone(); dt.Rows.Add(ds.Tables[0].Select("ID =" + ID)); Error message:Unable to cast object of type 'System.Data.DataRow' to type 'System.IConvertible'.Couldn't store <System.Data.DataRow> in Date Column. Expected type is DateTime. can anybody he...

Putting a YUI Button in DataTable

I've got a YUI DataTable with various columns that represents a list of users. I would like to add a column that contains a button in each row with a specific label (say, "grant access") and which invokes some function when clicked. Is this possible? I've tried checking the YUI documentation, but as far as I can see, they don't allow yo...

LINQ TO DataSet: Multiple group by on a data table

Hi, I am using Linq to dataset to query a datatable. If i want to perform a group by on "Column1" on data table, I use following query var groupQuery = from table in MyTable.AsEnumerable() group table by table["Column1"] into groupedTable select new { x = groupedTable.Key, y = groupedTable.Count() } Now I want to perform group...

Binding a Datatable to a Datagridview

Do you have any suggestions for my code below that you might have to improve the performance? This is .NET 2.0 framework, and the DataTable gets bound to a DataGridview. The data is loaded into the Datatable via .ReadXML() it doesn't come from a database. There can be any where from 80 to 100k of records. The Terms() array is what th...

Create table from existing DataTable/Dataset data with ADO.net ?

I need to create two tables. The first one I can get via database with a command. No sweat. The second one is built from the first one with nested SELECT statements, JOINs, and operators like SUM, AVG etc. So it needs more functionality than filtering and sorting. It is done in C# with .NET 2.0, so no advanced features available. Ess...

How can I improve my first OSS project

Hi, I am still visiting school and will finish my exams next year. Since two years I am working as (the only :-( ) in-house dev for a company providing financial services to Laboratories and doctors. After spending the first year fixing their existing Application and realizing, communicating and agreeing that it won't meet future requi...

Generic DataTable & TableAdaptor updates with Reflection (C#)

I have several strongly typed datasets throughout my application. Writing methods to update the data is getting tedious as each has several tables. I want to create one generic function that I can update all of the tables easily. I don't mind if I have to create one of these for each DataSet but if one function could handle all of them, ...

Searching DataTable (c# 2.0)

I know of existence of DataTable.Select(). It works great if you only need to find rows. What if you need to find and modify existing rows? I can't think of any other approach than implementing my own search function. Any input? I am using Compact Framework 2.0, c# ...

Maintain DataRowState in ADO.NET Dataset - RejectChanges() method does not work?

The problem simplified: I have a DataSet with some datatables... I have a Winforms DataGrid bound to one of the datatables. User sticks some rows into said datatable, via the DataGrid, let's say 3 rows; All three rows now have their RowState = DataRowState.Added. I now begin a sqlserver transaction. Then call dataAdapter1.Update(dat...

What is the most efficient way to store large amounts of data in a table in c#

I would like store large amounts of data (text) in a table with six columns and up to ten thousand rows. I will be building the table programatically. (Meaning I want to be able to add rows as I go) Is datatable my best option? I'm planning to bind it to a Telerik Grid Control for ASP.NET I am wondering I am better off going in with a...

Tables.Select on Unicode Characters

DataRow[] rows = myDataSet.Tables[0].Select("name = '" + _string + "'"); If _string contains UNICODE characters, do I need to prefix it with N like in TSQL? DataRow[] rows = myDataSet.Tables[0].Select("name = N'" + _string + "'"); Thanks! ...

Convert IEnumerable to DataTable

Is there a nice way to convert an IEnumerable to a DataTable? I could use reflection to get the properties and the values, but that seems a bit inefficient, is there something build-in? (I know the examples like: ObtainDataTableFromIEnumerable) EDIT: This question notified me of a problem handling null values. The code I wrote below h...

YUI Datatable & Large Data Sets w/o Pagination

I am currently implementing a YUI datatable as a reusable viewer to show sales reports (and other such things) for internal use. The problem is, many of these reports are up to, and even more than 1000 rows long, and client-side performance becomes an issue on even newer, faster machines. For a variety of reasons, server-side pagination...

winforms datagridview calculated field change event

I have a datagridview bound from a datatable. I have a calculated column linetotal that multiples unitprice * quantity. I also have a totalprice label,that I would like to contain the sum of the linetotal column in the datagridview. When the user makes any changes to unitprice or quantity, the linetotal should update for that line and...

winforms save datatable locally

In my application, I load a small datatable from a database and use the datatable to bind a column to a combobox dropdownlist. Everytime the combobox is shown, ibelieve it pulls data from the database which seems unnecessary as the data hardly every changes. Is there a way to load the datatable once in memory when the application open...

foreach loop question with datatable

i have a data table and i want to write a loop where i can render a html table and i want to do it from scratch (not abstracted data sources) i want to have the number of items per row a variable. what is the correct loop syntax given a datatable with X number of records where each record is one cell. so if i have 20 records and my Nu...

Best way to get random selection from DataTable?

As the title says, what's the most efficient way to get a random selection of x DataRows from a DataTable. Would it be to iteratively do something like the following until I have as many as I need? protected DataRow SelectRandomRow(DataTable dataTable, Random randomSelector) { return dataTable.Rows[randomSelector.Next(dataTable.Row...

Datatable select method ORDER BY clause

HI, I 'm trying to sort the rows in my datatable using select method. I know that i can say datatable.select("col1='test'") which in effect is a where clause and will return n rows that satisfy the condition. I was wondering can i do the following datatable.select("ORDER BY col1") ---col1 is the name of hte column I tried datatab...

C# passing ref type parameter issue

Hello everyone, Suppose I have the following code snippets, i.e. goo call foo, DataTable created by goo and foo will only call Rows.Add. Then goo will use the updated data of the DataTable instance from foo. My question is, in my scenario, any differences or benefits compared of using with and using without ref parameter? I am using C...