Questions tagged [datatable]

The term "datatable" is ambiguous. In .NET, it's a class that represents a table of in-memory data. In component based MVC frameworks like JSF and Wicket, it's an UI component that dynamically renders a HTML table based on a collection. For jQuery DataTables plugin, please use the [datatables] tag, for the data.table R package please use [data.table]. For the Python datatable package, use [py-datatable].

DataTable in .NET

A DataTable is a .NET class that represents one table of in-memory data. Unlike other programming languages and platforms, a .NET DataTable is not a GUI control but rather a representation of a SQL table directly accessible in code and a source of data for other controls.

A DataTable may exist as part of a DataSet, which represents an in-memory relational data store. In that context, they can be connected through instances of the DataRelation class, and constrained by ForeignKeyConstraint or UniqueConstraint instances.

A DataTable has a set of DataColumn instances, which describe its schema. Data is stored in DataRow instances.

A DataTable may be sorted and filtered without changing the data by attaching it to a DataView. The sorted and filtered rows are then accessed as instances of the DataRowView class.


DataTable in JSF

A <h:dataTable> is an UI component which allows you to render a HTML table dynamically based on a given List<Entity>. You can specify columns using <h:column>. Assuming that Entity is a fullworthy javabean with 3 properties id, name and value, here's an example how you can render a dynamically sized HTML table out of it:

<h:dataTable value="#{bean.entities}" var="entity">
    <h:column>#{entity.id}</h:column>
    <h:column>#{entity.name}</h:column>
    <h:column>#{entity.value}</h:column>
</h:column>

DataTable in Wicket

A data table builds on data grid view to introduce toolbars. Toolbars can be used to display sortable column headers, paging information, filter controls, and other information.

Data table also provides its own markup for an html table so the user does not need to provide it himself. This makes it very simple to add a datatable to the markup, however, some flexibility. (from Wicket 1.4.18 Javadoc)

22197 questions
4
votes
4 answers

How to count the number of rows in a HTML table?

I can't seem to find this anywhere. I have a dataTable like this one, and I want to be able to count the number of rows in the dataTable in javascript. how would that be accomplished? thanks! I need it in javascript because I want to iterate through…
Myy
  • 18,107
  • 11
  • 37
  • 57
4
votes
4 answers

reading a CSV into a Datatable without knowing the structure

I am trying to read a CSV into a datatable. The CSV maybe have hundreds of columns and only up to 20 rows. It will look something like this: +----------+-----------------+-------------+---------+---+ | email1 | email2 | email3 |…
Alex Gordon
  • 57,446
  • 287
  • 670
  • 1,062
4
votes
3 answers

Efficient way for updating data in a data table from another data table

I have a data table in my ASP.NET web service project, this data table has around 500K records in it with 39 columns and is present in Cache. After a minute a background thread hits the database and brings update records from database, which I want…
Imran Balouch
  • 2,170
  • 1
  • 18
  • 37
4
votes
2 answers

Is it possible to use IIF within SUM in a C# DataColumn.Expression?

This is the expression I'm trying to evaluate: Sum(IIF(QUALITY<=9.0,1.0,0.0)) The problem is that string expr = "Sum(IIF(QUALITY<=9.0,1.0,0.0))"; dataTable.Compute(expr, "") throws an error saying Syntax error in aggregate argument: Expecting a…
jcsmnt0
  • 973
  • 10
  • 15
4
votes
3 answers

Add entire row to DataTable at once using list

I just want to add List as a DataTable entire row. here is the code which I have tried. private static DataTable _table = new DataTable(); List tempList = new List(); // tempList =…
devan
  • 1,643
  • 8
  • 37
  • 62
4
votes
2 answers

C# looping through List> to populate a DataTable

I need to loop through a List of Dictionaries List> to populate a DataTable. Each Dictionary in the list has a Key, which needs to be the column name, and a Value which is what's in that column. The list contains 225…
Tonia Roddick
  • 137
  • 1
  • 3
  • 13
4
votes
2 answers

DataAdapter.Fill() behavior for row deleted at the data source

I'm using the DataSet/DataTable/DataAdapter architecture to mediate between the database and my model objects, which have their own backing (they aren't backed by a DataRow). I've got a DataAdapter with AcceptChangesDuringFill = False,…
John Calsbeek
  • 35,947
  • 7
  • 94
  • 101
4
votes
2 answers

Richfaces dataTable works fine, but ExtendedDataTable is not showing data

We are using Richfaces 4.1.0, and I am trying to use an extendedDataTable. I started (for simplicity's sake) with dataTable. The code below works fine, and shows my data in a table, as expected.
Innova
  • 1,751
  • 2
  • 18
  • 26
4
votes
4 answers

How do I get the last 5 rows of a datatable?

How do I get the last 5 rows of a datatable? I tried something like this: var Long_bottom = LongSlection.Last(5); Where LongSlection is a DataRow. But I had an error, any idea?
francops henri
  • 507
  • 3
  • 17
  • 29
4
votes
4 answers

Remove first, and last pagination from the jquery data table

I'm currently using jQuery Datatable. I also use jquery ui to provide good theme. However, I want to disable (hide) the first and last button of the pagination from the table by using a bit customization on jquery library. The problem is that the…
Tepken Vannkorn
  • 9,648
  • 14
  • 61
  • 86
4
votes
1 answer

How to discover that a DataColumn's underlying datatype is xml

I have a SQL Server data table that has an xml column. I run a select query using DataTable (Fill method of the SqlDataAdapter class). After execution, the type of the column is string. I am wondering how I could determine the actual SQL Server…
4
votes
2 answers

Many items in single order, SQL table design

I got one order table, when user come to the store they could purchase more than one item for example. may i know what is the best practices to perform such record action ? is that each item order one row in order table or mix all into one row in…
1myb
  • 3,536
  • 12
  • 53
  • 73
4
votes
2 answers

Sort DataTable rows by length in c#

How to do following scenario: I have some DataTable which contains for example some rows: 1.rowa 2.rowab 3.row 4.rowaba ... n. rowabba How to sort rows by lenght, not by name. I wan to to sort Table by length of fields.
nemke
  • 2,440
  • 3
  • 37
  • 57
4
votes
1 answer

DataTable to Excel range in one shot?

I've got some data in a System.Data.DataTable instance and want to put it an excel sheet range, directly, in one shot. I'm working with VS 2008 and my project is a C# Excel 2007 Workbook project. Thank you
Luis Quijada
  • 2,345
  • 1
  • 26
  • 31
4
votes
2 answers

the point of the Field extension method

What is the point of the Field extension method on DataRow (for untyped DataTables)? Here is a comparison of using Field or not using it. with Field: myRow.Field("myColName") without Field: (Guid)myRow["myColName"] I don't see any compelling…
JoelFan
  • 37,465
  • 35
  • 132
  • 205