datatable

C# Bind value of datagridview column to DataTable

I have a DataTable as a data source of a GridView. I'm adding a combo box the the GridView . I'd like to be able to add a column to the DataTable that would automatically update with the value the user selects in the GridView. Can anyone help? ...

Dynamic filter with dropdown list

Hi, I have a function that I want to call in a classmethod to dynamically add where condition but for some reason getting syntax error. Please help me with the code private DataTable CustomSearch<TKey>(this DataTable dt, Func<Records, bool> selector) { DataTable results = (dt.AsEnumerable().Where(selector).CopyToDataTable(...

How to combine two datatable together c#

I have two datatables. One is a superset of another. Both have one column StageID common. I need to merge these two tables together so that the subset datatables data gets stored in the correct row of superset table. This is what i did to join the data after retrieving the superset data in JoinTable and subset data in DTMaterialPropert...

How to sort DataTable by 2 columns, with NULLs, maybe using LINQ?

I have an ADO.Net datatable that I need to sort by first by column1 then by column2, either of which may have nulls. Once sorted I need to read some values out of the rows and add to a listview. I have written code to do this DataTable.DefaultView.Sort (run twice). But wondering if there might be a better way. I was thinking maybe ...

Moving to specific record within a DataTable

Hopefully simple, but can't find any such option. I have a data table -- has say... 10 rows in it. Some fields on the form are bound to the table.columns respectively by name. On another form that HAS a grid, as I scroll the grid, the detail fields are refreshed as expected since the grid does some magic to trigger the DataTable recor...

YUI DataTable : How to edit the column headers?

I would like to be able to edit the column headers in the same manner that I can alter row-values. Anyone come up with a way to do this? I don't see any mention of it in the docs. ...

A fast way for matching DataTable and String Array in C#

I have a DataTable with the following columns: id msisdn status another_column And a string[2][n] array (multi dimensional): {msisdn, status, useless_data} . . . I need start from 0 to n in string array and search for the msisdn field in data table. And update the status column in the datatable from the string arr...

C# how to change data in DataTable ?

Hello I'v got some problem, I use DataTable to store my data in dataGridView. Data was inputed like this: dt = new DataTable(); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("par", typeof(string)); dt.Columns.Add("max", typeof(int)); dt.Columns.Add("now", typeof(int)); dt.Rows.Add(...

"A relation already exists for these child columns" when using XSD.exe to generate DataTable Class

We've received an XSD (and XSX) file from a customer that defines the format of the XML file that we will receive from them. I've used XSD.EXE to create a Data Table class that I use in my C# project to access the information within the XML file. This has worked and I have an import library that is able to read in an XML file and spit ou...

Returning data from database in .net: Return a DataTable or LIst<T>?

I'm struggling with bridging the concepts of good database design with good object orientated design. Traditionally if I wanted to display a list of news stories in a repeater, I would use something like: <script runat="server"> void ShowNews() { rptNewsStories.DataSource = News.GetAllNews(); // Returns a DataTable r...

Performance Concerns between DataTable and SqlDataReader to fill Data with FlexGrid

Which one is more faster between DataTable and SqlDataReader while I'm trying to fill Data into FlexGrid with VB.NET? ...

asp.net finding column from dynamic gridview

Hi All, I'm creating a dynamic GridView from a DataTable that is returned from a stored procedure. I call and bind with the following code: DataTable dt = Sql.reportData(Convert.ToInt32(Session["userID"])); this.GridView1.DataSource = dt.DefaultView; this.GridView1.DataBind(); I need to restyle certain columns but they are not always ...

DataTable.GetChanges() keeps returning NULL!

I am trying to get all the rows that exist in allData but not in removeData public static DataTable RemoveDuplicateRows(DataTable allData, DataTable removeData) { removeData.Merge(allData); DataTable newData = removeData.GetChanges(); removeData.RejectChanges(); return newData; } removeData is empty prior to the...

C# DBNull and nullable Types - cleanest form of conversion

I have a DataTable, which has a number of columns. Some of those columns are nullable. DataTable dt; // Value set. DataRow dr; // Value set. // dr["A"] is populated from T-SQL column defined as: int NULL What, then, is the cleanest form of converting from a value in a DataRow, to a nullable variable. Ideally, I would be able t...

Customize DataColumn.Expression handling in C#

I would like to change behavior of DataColumn.Expression so that when I write: DataColumn.Expression = "MyMethod(Price)" it will call MyMethod, pass value from Price column into it and display evaluated value. How to acomplish this? ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#? ...

How can this code be optimized?

Hello all! I have a method which in essence converts a datatable to a list of objects which I call 'Bags'. This code is called many times per session, with many sessions concurrently running and with sometimes thousands of rows. Because of this I need it to be as quick as possible. I have an xml file which contains the DataColumn to ...

Using YUI in Javascript, How do I draw overlays on datatable/ScrollingDataTable?

I need to draw overlays spanning one or more rows on YUI datatable/scrollingdatable based on the mouse activity ( drag and drop ). I have no issues with drawing overlays on top of datatable. But I want the overlays to be moving along with the rows when I scroll the datatable. As of now after drawing the overlays they remain static ...

Dynamically render a DataTable into a Winform using the SSRS ReportViewer Control

BACKGROUND I'm writing a method that will (eventually) take as input a System.Data.DataTable and render it as an (simple,tabular) SSRS report into a Winform using the Microsoft's ReportViewer Control (http://www.gotreportviewer.com/) In order to do this I need to (1) dynamically create an RDL file based on the DataTable (2) load the RD...

C# Assigning a value to DataRow["haswhatnots"] = hasWhatnots is awful slow.

C# Assigning a value to DataRow["haswhatnots"] = hasWhatnots is awful slow. hasWhatnots is a boolean value. I have profiled this line and with 560000 hits the execution time is 82 seconds. Of course the profiler has some effect on the performance, but still the performance of this is grazy slow! Any hints on the issue. The DataRow is p...