datatable

Convert Yes/No/Null from SQL to True/False in a DataTable

I have a Sql Database (which I have no control over the schema) that has a Column that will have the varchar value of "Yes", "No", or it will be null. For the purpose of what I am doing null will be handled as No. I am programming in c# net 3.5 using a data table and table adapter to pull the data down. I would like to directly bind the...

bind a WPF datagrid to a datatable

I have used the marvelous example posted at: http://www.codeproject.com/KB/WPF/WPFDataGridExamples.aspx to bind a WPF datagrid to a datatable. The source code below compiles fine; it even runs and displays the contents of the InfoWork datatable in the wpf datagrid. Hooray! But the WPF page with the datagrid will not display in the des...

Unable to Export contents of Data table (with French formatted Numbers ) to XML

I have a data Table with numbers formatted according to the current regional settings. ie ( in French decimal separators are ',' instead of '.' in English). I need to export it to XML. Numbers in XML needs to be formatted according to the current regional settings.But now numbers in XML are formatted in English.Is there any way to make ...

Storing Data In ViewState From DataTable And Want To Back To DataTable After Inserting One More Row In DataTable

Hi I want to store data in viewstate from datatable and then want it back from viewstate to datatable. My problem: I m not able to add two rows in gridview from datatable. Plese ask for more information if not clear. ...

How to use JSF's h:selectBooleanCheckbox with h:dataTable to create one object per row?

I have a Facelets page with a h:dataTable. In each row of the h:dataTable there is a h:selectBooleanCheckbox. If the checkbox is selected a new Object should be created with the data out of the corresponding row. How do I do this? How to get the selected rows or their data in a backing bean? Or would it be better to do it with h:sel...

JSF inner datatable not respecting rendered condition of outer table.

<h:dataTable cellpadding="0" cellspacing="0" styleClass="list_table" id="OuterItems" value="#{valueList.values}" var="item" border="0"> <h:column rendered="#{item.typeA"> <h:dataTable cellpadding="0" cellspacing="0" styleClass="list_table" id="InnerItems" value="#{item.options}" var="option" border="0"...

Previous Data in Table .NET 1.1

How can I get the previous version of data of a Row in a DataTable? The data has only changed but hasn't been saved yet. The .NET version I'm working on is 1.1 ...

How do I get column names to print in this C# program?

I've cobbled together a C# program that takes a .csv file and writes it to a datatable. Using this program, I can loop through each row of the data table and print out the information contained in the row. The console output looks like this: --- Row --- Item: 1 Item: 545 Item: 507 Item: 484 Item: 501 I'd like to print the column nam...

Data table multiple row selection

How to change background color of row when I click the checkbox? ...

Combine two datatables in JSF 1.1

I have two datatables. One is to display names. Another contains three <h:selectOneMenu>. I want combine those two datatables. I don't know how to do it? Expected result: ----------------------------------------------- Datatable1 Datatable2 ----------------------------------------------- Lic Date month year Premium ...

How can I add the column data type after adding the column headers to my datatable?

Using the code below (from a console app I've cobbled together), I add seven columns to my datatable. Once this is done, how can I set the data type for each column? For instance, column 1 of the datatable will have the header "ItemNum" and I want to set it to be an Int. I've looked at some examples on thet 'net, but most all of them ...

Get the corresponding row in the datatable from the selection in datagridview

Hi All, I have a DataTable which is bound to datagridview (Winforms)... I use the following two lines to get the DataRow that is selected in the datagridview... int l_intSelectedRow = DataGridView1.SelectedRows[0].Index; DataRow l_drwSelectedRow = ControlGroupPostedItems.Tables["PostedItems"].Rows[l_intSelectedRow]; ...

how to bind the converted value from a datatable to my gridview.

how to bind the value to gridview i have a datatable DataTable dtBindGrid = new DataTable(); dtBindGrid = serviceobj.SelectExamTimeTable(txtSchoolName.Text, txtBranchName.Text, txtClass.Text, txtExamName.Text); foreach (DataRow row in dtBindGrid.Rows) { strgetday= row["Day"].ToString(); strgetdate = row["...

Fastest way of creating XML from parent-child table in c#?

Assume we have some DataTable or IEnumerable with ChildID, ParentID and Title. We need to serialize it to XML like <Entity title=""> <Entity title=""></Entity> <Entity title=""></Entity> </Entity> As i found out, standard DataTable.GetXML() returns something different. I thought about initializing class tree like Entity e = n...

Alternatives of Datatable

In my web application, I have a dynamic query that returns huge data to datatable, and this query is often recalled with different parameters. So database is exhausted. I want to get all record with no parameters to an object, and perform queries (may be with linq) on this object. So database will not be exthausted. Which objects can b...

DataGridView.CellValueChanged not firing on bound DataGridView

When I change a value programatically in a DataTable that my DataGridView is bound to, the appropriate CellValueChanged event is not firing for the DataGridView. I'm trying to change a cell's background color based on cell value when the DataTable is filled with data without iterating through every row and checking each value. ...

How can we copy the data of the datacolumn of the datatable to another datatable ?

How can we copy one datacolumn with data from one datatable to another datatable ? I have datatable like DataTable datatable1=new DataTable(); and there are four columns in that table but I want only one column.So I am doing like DataTable datatable2=new DataTable(); addressAndPhones2.Columns.Add(addressAndPhones.Columns[0].ColumnNa...

Writing datatable to database file, one record at a time

I want to write a C# program that will read a row from a datatable (named loadDT) and update a database file (named Forecasts.mdb). My datatable looks like this (each day's value is a number representing kilowatts usage forecast): Hour Day1 Day2 Day3 Day4 Day5 Day6 Day7 1 519 520 524 498 501 476 451 My databa...

How can we copy the column data of one datatable to another,even if there is different column names of different datatable ?

I have two datatables. First is DataTable NameAdressPhones = new DataTable(); with Three columns Name,Adress and PhoneNo.But I want only two columns Name and Adress data so I am copy those columns (with data) to the new datatable DataTable NameAdress = new DataTable(); For that I do foreach (DataRow sourcerow in Nam...

Sum values in a DataTable by a given criteria

Which is the most effective way to sum data in the DataTable by a given criteria? I have the following table: KEY_1 KEY_2, VALUE_1, VALUE_2 Input: 01101, P, 2, 3 01101, F, 1, 1 01101, P, 4, 4 10102, F, 5, 7 Desired output (new DataTable): 01101, P, 6, 7 01101, F, 1, 1 01101, SUM, 7, 8 10102, F, 5, 7 10102, SUM, 5, 7 I need effi...