Click here to Skip to main content
15,887,386 members
Everything / DataTable

DataTable

DataTable

Great Reads

by Alex Pumpet
A simple program for comparing table data from two sources - SQL databases, Excel, CSV or XML-files
by Jovan Popovic(MSFT)
Reordering table rows using drag and drop functionality with jQuery DataTables plug-in in ASP.NET MVC applications
by Massimo Fabiano
I know that "returning DataSets from WebServices is the spawn of Satan" but...
by Proneetkumar Pradeep Ray
JQuery Datatable (Dynamic columns) populate after Ajax JSON response via server side processing - Using EF Raw SQL query

Latest Articles

by DiponRoy
The aim of this helper class is to divide a large IEnumerable into multiple small list.
by DiponRoy
The aim of this helper class is to divide a large datatable into multiple small datatables.
by Stefan Vincent Haug
Helper method to apply sorting from DataTables.js parameters in C#
by WyoMetz
Simple and easy paging of a WPF DataGrid with DataTable and LINQ queries

All Articles

Sort by Updated

DataTable 

U 27 Apr 2024 by Member 12760369
I am trying to fill an HTML table through a datatable which brings information from a database. Within the ajax parameters to bring the information from the database there is a piece of information that allows me to only extract the records of...
23 Jan 2024 by Zain Khan 2024
It looks like you want to validate data in an Excel file and add an error message to a new "Error" column for rows that contain invalid data. Additionally, you want to download the Excel file with the added error information. Here's a suggested...
19 Jan 2024 by Akshay malvankar
Hi I want to validate datable and if there is an any error in row of data table then i want add Error Msg in Error Column "Excel D: column contain Invalid data". in that row which consist error in row. and if any error occured i want to download...
9 Dec 2023 by Dave Kreskowiak
DEBUGGER! Ruin the code under the debugger and set a breakpoint on the line that fills the DataSet. Execture the code one line at a time and hover the mouse over variables to see their content. You could have figured this out in seconds! The...
9 Dec 2023 by Member 4529316
I have a Dataset with results I get from the DB, I keep that as a base dataset and would like any filtering will be done on the second Dataset. I ensure I have the filtered data on datatable but when I use dataset.table.add the dataset is...
27 Jun 2023 by Akshay malvankar
I have one datable consist around 25000 record datable look like this Id Name Lname bday 1 abc hdhd 25-02-1991 2 cnd dhdhd 7-05-1995 3 dhdhd ddjd 15-07-1993 4 dhhdd ddddhd 05-09-1999 i am converting above...
27 Jun 2023 by OriginalGriff
This is your 49th question, pretty much all of which can be answered with a trivial google, or a little knowledge of the classes you are playing with. In this case, it's simple to work out what you need to do by thinking about a DataTable and...
13 Jun 2023 by Anil Kumar Apr2022
My main view is able to plot data in DataTable. There is a button to save the entire table to database. But I am unable to send this entire table to my Controller's ActionResult. Here is my Codes: - User_Auth_List.cshtml @model...
13 Jun 2023 by Ethinix Salon
In your view, ensure that the table is wrapped within a form tag, which will allow you to submit the data to the controller. Assign a unique name attribute to each table row or input element within the table. This is crucial for binding the data...
23 Apr 2023 by Member 13998042
Dear team i am trying to save a textbox value in db using ajax which is inside the jquery datatable . My Datatable is below $(document).ready(function () { var empid = '@ViewBag.empid'; $.ajax({ ...
20 Apr 2023 by chandra sekhar
if (NSFwithExtOrSerFound) { int count = 0; foreach (DataRow recRow in dtRec.Rows) { if (recRow[0].ToString() == "Contact Vibration Specialist") ...
5 Apr 2023 by Member 15970846
To pass the jQuery DataTable post parameters to an external ASP.NET Core Web API, you can follow the below steps: Add the necessary jQuery DataTable post parameters to the HTTP request body in the Postdata action method of the WEB API project....
5 Apr 2023 by chocusatergus
I'm struggling with: I have a Database-WEB API -Web application tier. My web application has a jquery datatable which post its request to the following method in the WEB API public class DataTableAjaxPostModel { public int? draw {...
5 Apr 2023 by Nima Naghdi
To answer your first question, yes, the datatable parameters should bind automatically to the DataTableAjaxPostModel class when it's sent to the Postdata method via the HTTP POST request. Regarding your second question, the code seems okay, but...
4 Apr 2023 by Member 13998042
Dear mentors i am working on a asp.net core mvc .net 6 project where i have a view in which i am making a ajax call to load data to a datatable the ajax call and the datatable loads script is as follows function fetchIndexforhrvalidate() { ...
22 Mar 2023 by John Ertle Jr
Want to display a dataTable in C#. I am using : "using System.Data" as a directive. Where am I going wrong? DataTable dt0 = new DataTable(); dt0.Columns.Add("", typeof(string)); dt0.Columns.Add("Sun", typeof(double)); ...
22 Mar 2023 by Gee Varghese
I have a DataTable which has two columns, id and date (which is in DateTime format -> yyyy-dd-MMThh:mm:ss).I have a requirement of showing data that corresponding to this month. How is it possible ?
22 Mar 2023 by hisham elmsry
LINQ-To-DataSet (which i prefer): var filtered = tb.AsEnumerable() .Where(r => r.Field("CREATOR").Contains(searchstring)); ADO.NET(DataTable.Select): DataRow[] filteredRows = tb.Select("CREATOR LIKE '%" + searchstring + "%'");...
22 Mar 2023 by hisham elmsry
ADO.NET(DataTable.Select): DataRow[] filteredRows = tb.Select("CREATOR LIKE '%" + searchstring + "%'"); ADO.NET(DataView.RowFilter): tb.DefaultView.RowFilter = "CREATOR LIKE '%" + searchstring + "%'";
13 Feb 2023 by Grant Mc
Hi. Lets say I have a collection called Orders, and one of the members in the collection, is another collection called Products. So if I have an order, say ID = 001, and it has two different products, I would like to show this on a DataGrid,...
13 Feb 2023 by Grant Mc
OK, still working through this, but here is what I have so far. public partial class MainWindow : Window { MovieCollectionViewModel movieCollection; ObservableCollection actors; public MainWindow() { ...
12 Feb 2023 by Graeme_Grant
This link will show you how: DataGrid with row details - The complete WPF tutorial[^] Here is a little demo with Order > Product grouped data structure: public partial class MainWindow : Window { public MainWindow() { ...
16 Jan 2023 by Member 12694392
Data in DataTable as Time Col1 Col2 10:00 1 11:00 2 10:00 3 11:00 4 I need to arrange it as Time Col1 Col2 10:00 1 3 11:00 2 4 What I have tried: I currently used 2 different table for merging, which is consuming...
16 Jan 2023 by Member 12694392
Maciej Los your solution works for specific column count and data gets stored in List. I achieved the same with below logic and in datatable only. DT1.Columns["value"].ColumnName = TagNamePlain; DT1.PrimaryKey= new DataColumn[] {...
16 Jan 2023 by Maciej Los
Note: your data are stored in wrong way... I'd suggest to join data in col1 with col2 based on time column. Take a look at below code: DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn("Time",...
16 Jan 2023 by Graeme_Grant
I have never used RDLC. I am going to assume that RDLC DataSource binding works the same as other WinForm controls, like the DataGridView. My thoughts are: * use a single DataTable, not 2. * Add a filter column to the DataTable - FilterColumn...
9 Jan 2023 by John Ertle Jr
Adding GridView completes the DataTable GridView1.DataSource = dt0; GridView1.DataBind();
2 Jan 2023 by BillWoodruff
A DataView is not a user-interface element, it is aQuote: Represents a databindable, customized view of a DataTable for sorting, filtering, searching, editing, and navigation. The DataView does not store data, but instead represents a connected...
21 Dec 2022 by Thang Đai
I have a table that stores people's data by month and I want to display the data by the current month and when I enter it in the search box, it will still display the information of the entered month. What I have tried: I have tried several...
6 Dec 2022 by Harry Pachty
So I am trying to improve my knowledge about C# and I have found a website called https://www.dotnetperls.com/ which has many examples on data structues and algorithms. Also about datatables: https://www.dotnetperls.com/datatable. The secound...
6 Dec 2022 by Richard Deeming
If you want to share code between applications, then you'll need to create a "class library" project, and reference it from both applications. Create a .NET class library using Visual Studio - .NET | Microsoft Learn[^] In the class library: ...
6 Dec 2022 by Richard MacCutchan
I think maybe the detail was not clear. What you need to do is to copy the actual text of the GetTable method from the first source file, and paste it into the second. So your second source file should then look like: using System; using...
21 Nov 2022 by Member 15839423
Hi All, I am trying to design a web application using Django. The application requires to use Materializecss, jQuery (DatePicker and Select2) and Datatables. My challenge is to include the necessary .css and .js files only once in base.html such...
21 Nov 2022 by Kornfeld Eliyahu Peter
It is only possible if base.html functioning as a base/master page - which is not supported in plain html, but supported in many development packages... Like Django templating... Django | Creating and Using MasterPages[^]
18 Oct 2022 by f*rcklift2030
I'm a C# newbie working on a Winforms project and need help retrieving and displaying picture to picturebox. However, I'm getting an error "Unable to Cast object of type String to type byte[]" There are other elements such as Navigation that...
10 Oct 2022 by Nazmul Hossain Shanto
I want to highlight specific rows while printing data from the jquery data table. I added a class to those rows by createdRow and added some CSS style to that class. Now I want to keep that styling on those rows while printing. ...
2 Sep 2022 by khraLiezx
In this way, the data comes from the database in a mixed way with different prices. 1. Product = Laptop Price=100 Quantity=105 2. Product = Monitor Price=110 Quantity=130 3. Product = Tel Price=200 Quantity=250 4. Product= TV ...
2 Sep 2022 by CHill60
Richard's idea is a good one and simple to implement. However it does not cater for growing data. I suggest that you extract the data as individual rows (per product per price) and then pivot that datatable to produce another Here are a couple...
23 Aug 2022 by Richard MacCutchan
See datatable django - Google Search[^].
23 Aug 2022 by Qbit Contable
Good morning fellows. We have a website with a search engine that returns data organized in cards, and we want it to work with instant search like a datatable does. Do you know how we can do it? We use python and django. Thanks a lot!! What I...
20 Aug 2022 by nyt1972
Hello, My table has two header rows, DataTable is showing bother header rows but not exported to pdf please help. My table is:
22 Jun 2022 by nyt1972
Hello, I have an issue that if I use DataTables Ajax render function for a conditional column it duplicates each row in table. If I remove the below line then it works fine, but after adding this every row is displayed twice. { ...
21 Jun 2022 by Truecolors
I have a jQuery DataTable with server-side processing which is giving me circular dependency issue. I have to list a field `Administrator` in my DataTable that belongs to another class. If I include it in the code, I get dependency errors with Ajax like > DataTables warning: table...
2 Jun 2022 by Manojkumar-dll
i have to use two string values inside a column to get the results and ,i cant use that it shows as " No Overload for method 'Contains' takes 2 arguments " is there any way to overcome this What I have tried: data = data...
2 Jun 2022 by OriginalGriff
The error is telling you that whatever class Contains is being called on (and we have no idea what type any of the properties of your class you are calling it on are) the definition does not contain a version which takes two parameters. So start...
2 Jun 2022 by Dave Kreskowiak
You cannot specify a field inside the argument for Contains. We don't know anything about your object strucutre, so it's impossible to be precise, you would be looking for something closer to this: data = data .Where(p =>...
22 May 2022 by Carol H
I wanted to display binary image from my database in Jquery datatable, I have tried a few ways but did not work as well. This is my DataTable: "columns": [ { "data": "Product_ID" }, { "data": "Product_Name" }, { "data":...
22 May 2022 by vipan.net
Work for me "columns": [ { "data": "profile_pic", "render": function (data, type, full, meta) { return ''; } }, From url: { "data": "imageUrl", "render": function(data, type, row) { ...
12 May 2022 by Manojkumar-dll
I have to Bind the datas from a Column in datatable into a custom search dropdown using jquery What I have tried: This is the HTML Part
12 May 2022 by Richard Deeming
So many things wrong with that code... Your element has an ID of ddl_type, but your script tries to reference an element with the ID ddltype. Those are two completely different IDs. You declare an array variable called $duplicate, but...
13 Feb 2022 by Khatanbaatar Bilguun
You can see two data tables in the attached photo. The first data table shows the same data in all three rows. I don't need the duplicated datas, so I want to remove the duplicated row of datas and make only one row of data. Please tell me what...
7 Feb 2022 by #realJSOP
There's at least one article here n CP that describes some methods for doing this: Different Ways to Pass Data to Partial View[^]
5 Feb 2022 by Graeme_Grant
You are looking at it backwards. The GridView, as the name implies, is a view into the data. So you filter/search the data and display the results in the GridView. UPDATE I did a quick Google Search and found this: Search records in GridView...
5 Feb 2022 by Tinsae Teku
Most search features of grid view in ASP.NET shows how to search data from a data list that is connected to a database. But my data in my gridview is list of name of books from a folder. It uploads files from folders and save them on visual...
5 Feb 2022 by Niklas Arabäck
Hi I'v been looking thrue the hole internet for a solution of interpolating a datatable but can't find a good answer. I have a datatable with about 10 columns(double). The first column index in the data table is the x axel. and the rest needs to...
5 Feb 2022 by Gerry Schmitz
You need at least one record / row that doesn't have "empty columns". That row and the "x" (x1) is then your base. "Interpolation" implies finding the value between two other values; however, since the columns are a funtion of x (I assume), you...
28 Jan 2022 by Alex Dunlop
I use jQuery DataTable in my ASP.NET MVC project. One of my databasecolumns gives true/false values. I want to translate its value to a string and changes its color. I tried following code for this column: "columns": [ ...
28 Jan 2022 by M Imran Ansari
Not sure what datatype is coming into your data object. First thing you need to check the data coming in your response. Secondly, You are checking with irrespective of the datatype of variable. If you are sure the data is boolean in response...
28 Jan 2022 by Sam_gaik
Is there a way to compare three datatables? The three datatables will have the same columns, but I want to check the rows of SNAME which are not in the rest of the tables. Also, the values of the SNAME column and its respective all column values...
28 Jan 2022 by M Imran Ansari
For environment setting and set-based operations with challenges of non-keyed tables. to perform row-to-row changes, kindly review the following link: https://www.sqlshack.com/compare-tables-sql-server/
27 Jan 2022 by Luc Pattyn
I expect your code to fail as it implicitly assumes one row index in three tables will produce the same SNAME value, which your example data does not. You seem to want an INNER JOIN of three DataTables? With database tables and SQL that should...
15 Dec 2021 by George Swan
It seems to me that working with DataTables is not easy as lots of casting is needed in order to extract anything more meaningful than an object from them. I would do something like this to get the required column names from table1. ...
15 Dec 2021 by Member 10252017
DataTable1 columnName colGroup ----------------- --------------- OriginCompany YES OriginAddress YES OriginZip OK OriginState NO DataTable2 OriginCompany OriginAddress OriginZip OriginState ------------ ...
14 Dec 2021 by Gerry Schmitz
Maybe not the most efficient, but with few columns, shouldn't make much difference. asp.net - Remove columns from DataTable in C# - Stack Overflow[^] So, remove any "not" in the selected list of columns.
30 Nov 2021 by Gireesh B
Dataset. Tables. Clear() and Datatable. Rows. Clear() Not clearing the data. Data appending every time. Please help me What I have tried: Ds = new dataset( table name) Ds. Tables. Clear() Ds. Reset() Dt = new datatable(table name) Dt. Rows....
30 Nov 2021 by OriginalGriff
I suspect that that code isn't being executed, or isn't affecting the tables you think it is: Dt = new datatable(table name) Dt. Rows. Clear() Dt. Columns. Clear() Dt. Reset() The last three lines are irrelevant, as the DataTable is already...
25 Oct 2021 by Grid-Code
Good Day This may be a stupid question but... If you have a public datatable used for info between programs visual studio Public Shared DtRptDisc As New DataTable("DtRptDisc") If the case scenario is that you want to refresh the datatable and...
25 Oct 2021 by Richard Deeming
Quote: DtRptDisc = New Datatable Is this creating a duplicate instance ? or recreating the same instance? It creates a new DataTable instance, and clears the reference to the old one from the field. If you have used the value of that field...
22 Oct 2021 by RickZeeland
If you want to make sure the DataTable is disposed, you can use a using clause in C# like this: using (DataTable table = new DataTable()) { // your code } For the VB.NET syntax see: Using Statement - Visual Basic | Microsoft Docs[^]
22 Oct 2021 by SherryT6$
I have a datatable that gets data from database. What i want to do is that when a record is changed in the table , it should automatically be reflected in the datatable "without" refreshing the page. How can this be done? I tried using deferRender but it doesnt seem to work.Where am i going...
25 Aug 2021 by Abdelrahman-Dev
Hello, I have a C# winform application for selling books, And in my selling form I have some textboxes where the user can enter the name of the book, the amount, the price, etc... I have a button for inserting these values into an Access...
25 Aug 2021 by Richard Deeming
Quote: string cmdInsert = @"INSERT INTO SoldProducts (BookName, Amount, Price) Values('" + Convert.ToString(r.Cells[0]) + "', '" + Convert.ToString(r.Cells[1]) + "', '" + Convert.ToString(r.Cells[4]) + "')"; Not like that! Your code is...
16 Aug 2021 by Abdelrahman-Dev
Hi, Thanks for viewing my question. I have a button in my form which is responsible for inserting the values inside the textboxes into a datagridview, I have another button that takes all the rows inside the datagridview and inserts them to my...
15 Aug 2021 by Dave Kreskowiak
Access databases do not support stored procedures. You have to run the SELECT query in your code, analyze the return value from the query, then decide whether to execute the INSERT query.
15 Aug 2021 by Abdelrahman-Dev
I have a button that is responsible for inserting the values inside the textboxes into a datagridview, and then another button responsible for inserting every row in that datagridview into the access datatable by looping through them and...
15 Aug 2021 by OriginalGriff
The simplest solution is to do an UPDATE operation and then INSERT if it fails: I'd create a stored procedure called InsertOrUpdate and do it there: CREATE PROCEDURE InsertOrUpdate @ProductName NVARCHAR(MAX), @Amount INT, @Price...
21 Jul 2021 by SirNoN
vb.net I want To copy DataTable To anther DataTable with other columns What I have tried: datatable.copy datatable.clone
21 Jul 2021 by Member 14180938
Use this without Loop Dim ds as New DataSet ds.tables.add(dt.Copy)
3 Jun 2021 by Ms Dinosaur Bamboo
Dear all, I am not idea to save row data into another database from DataTables using EF MVC. Thank You appreciate for your help. What I have tried: My dataTables can show on data on screen but not idea to save another database when pressed...
22 May 2021 by DSFVDSCSDC
I cannot import the json content in the example into the tables with the standard displayed codes. How do I convert nested data to datatable? What I have tried: public class Location { public double lat { get; set;...
22 May 2021 by Sandeep Mewara
You can use any online JSON to C# class converter for the same: // Usage // Root myDeserializedClass = JsonConvert.DeserializeObject(myJsonResponse); public class Location { public double lat { get; set; } public double lon {...
3 May 2021 by Divyay208
I am using jQuery data tables to display data in grid format with EDIT and delete options respectively, and grid having paging with 15 records per page. I am able to display records using ajax call on grid, here when user click on edit I am...
28 Apr 2021 by stormie2
I have a datatable with a Search functionality having 2 input boxes - one to input minimum age and one to input maximum age. The datatable does not have a column age but rather a column DOB in date format. Now I need to search max/min age based...
28 Apr 2021 by W Balboos, GHB
You're overcomplicating this. You get the current date. Adjust the year datepart to your min and max range but keep the rest of the current date unchanged.* Test your table of dates (DOB field) to determine if it's between these dates...
21 Apr 2021 by Shruti Metta
Please let me know, where I'm going wrong. I have a button and on its click , it calls 'GetSelectedRecords()' , where im trying to fetch the multiple selected row values. my script code below function GetSelectedRecords() { var table =...
21 Apr 2021 by Richard Deeming
You seem to be trying things at random, without reading the documentation. rows()[^] row-selector[^] Try: var allData = $('#gridview').DataTable().rows(".selected").data().toArray();
29 Mar 2021 by huynbt209
My first time working with Datatables and SweetAlert2. I have a problem in laravel for confirming the post delete by sweetalert2. I have the following code but the confirm modal is useless, as the request pass it and user don't even have time...
29 Mar 2021 by Richard Deeming
You need to prevent the browser from following the link. You'll also need to navigate to the link, or perform an AJAX request, when the user confirms the deletion. Otherwise, nothing will actually be deleted. $('#UserFacultyTable...
25 Mar 2021 by Slow Eddie
I have never understood writing to a console. I have created a data table but need to view it to make sure I am saving the correct data in the correct order. I found a vb.net example on Microsoft's on-line help but it requires writing to the...
25 Mar 2021 by OriginalGriff
Unless you are writing a Console app (instead of a WPF or WinForms app) you don't normally have a console - instead Console.Write commands write to the Output pane of the debugger (as do Debug.Write commands). It is possible to add a Console to...
17 Mar 2021 by huynbt209
Hello ,I want to check the Article's Status, if true the Edit button will be disabled else the user can click and switch to the Edit page. How to use it? $(document).ready(function () { var table = $('#studentArticleTable').DataTable(); ...
17 Mar 2021 by SeanChupas
@Model.Status will affect every record. Is that what you want? Are you sure you don't want to check a value of the particular row? It's really easy. In your render event get a value like this: var rowvalue = row["some_field_in_dataset"];...
15 Mar 2021 by TheBigBearNow
Hello everybody, I have a DataGrid that is being populated from a DataTable by a SQL database. My SQL creates a list of objects and I create the datatable and columns dynamically. I am trying to set the column width of each column so I can specify them to whatever width I want. My grid view is...
15 Mar 2021 by aherceo
public ProductsList() { InitializeComponent(); CreateProductList(); DataTable dt = DataTableProductList(productList); // it is assumed that productList is a public variable of type List ...
1 Feb 2021 by Member 15061586
i chose the last solution.solution 2. but after the table name there is no acceptchanges() option.
6 Jan 2021 by Godservant
I'm using datatable to insert records to my database in sql server and the reason why I'm using datatable is because the records to be inserted is on the datagridview. my question is, how can I check or validate records just in case I...
6 Jan 2021 by thatraja
You didn't include query from SP. It's hard to guess without seeing that. But you can prevent duplicates by using CONSTRAINT(For example SQL PRIMARY KEY Constraint[^] ) & checking existence of data(use SQL SELECT Statement[^] with WHERE clause...
2 Jan 2021 by faisal23
Hello Guys, I am using a data table to show the grid. There is select all option to select multiple records. My problem is when I selectAll it will select all records even if searched for particular Id. What I have tried: My Datatable: ...
17 Nov 2020 by faisal23
Hello, I am using DataTable to export into Excel. In one of my cell using a long number which is automatically rounding off when exported to Excel. EG. 1921213425466648 This number converted to 1921213425466650 I need to keep it as it is. ...
17 Nov 2020 by faisal23
Hello, I solved it using the below line of code. "buttons": [{ extend: 'excel', exportOptions: { orthogonal: 'sort' }, customizeData: function ( data ) { for (var...