How to Read text file to DataTable [closed]

This is a simple method to do your job public DataTable ConvertToDataTable (string filePath, int numberOfColumns) { DataTable tbl = new DataTable(); for(int col =0; col < numberOfColumns; col++) tbl.Columns.Add(new DataColumn(“Column” + (col+1).ToString())); string[] lines = System.IO.File.ReadAllLines(filePath); foreach(string line in lines) { var cols = line.Split(‘:’); DataRow dr = tbl.NewRow(); for(int cIndex=0; cIndex < 3; … Read more

deserialize a datatable with a missing first column

Json.NET is open source under the MIT License, so one possibility would be to create a modified version of its DataTableConverter to suit your needs. Its source code is available here. First, create your own forked version of this class, called, say, JsonDefaultTypeDataTableConverter<T>. Modify the method GetColumnDataType to return typeof(T) for a null column value: … Read more

Create table columns dynamically in JSF

You can achieve this with standard JSF components using a <h:panelGrid> wherein <c:forEach> is been used to generate the cells during the view build time. The <ui:repeat> won’t work as that runs during view render time. <h:panelGrid columns=”5″> <c:forEach items=”#{bean.items}” var=”item”> <h:panelGroup> <h:outputText value=”#{item.value}” /> </h:panelGroup> </c:forEach> </h:panelGrid> As to component libraries, I don’t see … Read more

jQuery DataTables “No Data Available in Table”

Please try to initiate the dataTable after your AJAX loaded table is appended on body. $ ( document ).ready(function() { $.ajax({ type: ‘GET’, url: ‘models/summary.php’, mimeType: ‘json’, success: function(data) { $.each(data, function(i, data) { var body = “<tr>”; body += “<td>” + data.name + “</td>”; body += “<td>” + data.address + “</td>”; body += “<td>” … Read more

How do I use SELECT GROUP BY in DataTable.Select(Expression)?

DataTable‘s Select method only supports simple filtering expressions like {field} = {value}. It does not support complex expressions, let alone SQL/Linq statements. You can, however, use Linq extension methods to extract a collection of DataRows then create a new DataTable. dt = dt.AsEnumerable() .GroupBy(r => new {Col1 = r[“Col1”], Col2 = r[“Col2”]}) .Select(g => g.OrderBy(r … Read more

Returning DataTables in WCF/.NET

For anyone having similar problems, I have solved my issue. It was several-fold. As Darren suggested and Paul backed up, the Max..Size properties in the configuration needed to be enlarged. The SvcTraceViewer utility helped in determining this, but it still does not always give the most helpful error messages. It also appears that when the … Read more