what's the Difference between DataView and DataTable?

Answers were Sorted based on User's Feedback



what's the Difference between DataView and DataTable?..

Answer / guest

data tables holds all the rows of the table where as date
view hold te filtered or reqired rows that are been retrived
on a particular condition

i think my answer is correct

Is This Answer Correct ?    95 Yes 23 No

what's the Difference between DataView and DataTable?..

Answer / ahmed yassin

DataView Object provides a window into a DataTable that can
be sorted and filtered using the Sort,RowFilter, and
RowStateFilter properties.It also contains the AllowDelete,
AllowEdit,AllowEdit, and AllowNew properties to constrain
user input as needed.

DataTable can have many DataView objects assigned to it,
allowing the data tobe viewed in many diffirent ways
without requiring the data to be reread from the database.

Example:::

DataTable customer = GetDataTable() //ur datable method
// add new datarow by adding the values
customer.Rows.Add("73OOFUFU","Mohamed","Ilyas",2533.00m);
customer.Rows.Add("3636366H","Idriis","Yassin",25545.00m);
//Sort and display
DataView view = new DataView(customer);
view.sort = "LastName ASC, FirstName ASC, Salary DESC";
GridView gv = new GridView();
gv.EnableViewState = false;
form1.Controls.Add(gv);
// assing ur gridview to dataview
gv.DataSource = veiw;
gv.DataBind();
*********************************
Sorry if there is some misspelt.

Is This Answer Correct ?    48 Yes 7 No

what's the Difference between DataView and DataTable?..

Answer / kuldeep paliwal

the dataview class that enable you to create various views
of the data stored in the data table.dataview is use to
filter the data in datatale.it can also be use to
add,modify and delete the row in datatable.datatable is
object contain one or more column each repersent by a
datacolumn object.

Is This Answer Correct ?    25 Yes 10 No

what's the Difference between DataView and DataTable?..

Answer / rajesh kumar chekuri

DataTable: Represents one table in-memory
DataView:: Represents a customized view of a DataTable for
sorting, filtering, searching, editing, and navigation.
See the following example u can get Better idea...

// Create a new DataTable.
System.Data.DataTable table = new
DataTable("Customers");
// Declare variables for DataColumn and DataRow objects.
DataColumn column;
DataRow row;

// Create new DataColumn, set DataType,
// ColumnName and add to DataTable.
column = new DataColumn();
column.DataType = System.Type.GetType("System.String");
column.ColumnName = "ID";
column.ReadOnly = true;
column.Unique = true;
// Add the Column to the DataColumnCollection.
table.Columns.Add(column);


// Create second column.
// Add the column to the table.
table.Columns.Add("FirstName",
System.Type.GetType("System.String"));

// Add the column to the table.
table.Columns.Add("LastName",
System.Type.GetType("System.String"));

// Make the ID column the primary key column.
DataColumn[] PrimaryKeyColumns = new DataColumn[1];
PrimaryKeyColumns[0] = table.Columns["id"];
table.PrimaryKey = PrimaryKeyColumns;


// add new datarow by adding the values
table.Rows.Add("C101", "Rajesh", "Kumar");
table.Rows.Add("C102", "Fareed", "sk");
table.Rows.Add("C103", "Rajesh", "Raji");

//Sort and display
DataView view = new DataView(table);
view.Sort = "LastName ASC, FirstName ASC";

// assing ur gridview to dataview
GridView1.DataSource = view;
GridView1.DataBind();

Is This Answer Correct ?    18 Yes 9 No

what's the Difference between DataView and DataTable?..

Answer / ajay

DataTable: Represents one table in-memory
select distinct field from the filtered dataview

Is This Answer Correct ?    9 Yes 4 No

what's the Difference between DataView and DataTable?..

Answer / surya pratap singh

The dataview class that enable you to create various views
of the data stored in the data table.dataview is use to
filter the data in datatale.it can also be use to
add,modify and delete the row in datatable.datatable is
object contain one or more column each repersent by a
datacolumn object.

Is This Answer Correct ?    4 Yes 2 No

what's the Difference between DataView and DataTable?..

Answer / zana

From you'll answers, i have a question: If i selected a row
from a datagrid bound to a dataview, how would i determine
which row in the datatable corresponded to the row i
selected? Let say i just needed to know which row in the
datatable my selection corresponded to.

Is This Answer Correct ?    10 Yes 12 No

what's the Difference between DataView and DataTable?..

Answer / satish

Data Table are also the filter rows of dataset(Virtual
table of database) whereas the dataview is only the
filtered view of the original database.

Is This Answer Correct ?    24 Yes 34 No

what's the Difference between DataView and DataTable?..

Answer / kamalakannan

1. Filter and sort the datatable or dataset.

2. select distinct field from the filtered dataview.

3. Datatable select function gives datarow array, but
dataview gives the datatable. The function easy to return
the dataview.

4. code will be reduced compare than datatable select
function.

Kamal..

Is This Answer Correct ?    8 Yes 27 No

what's the Difference between DataView and DataTable?..

Answer / aman kulkarni

Data Table is very very good and is useful.Dataset is very
bad and nonsense

Is This Answer Correct ?    20 Yes 80 No

Post New Answer

More C Sharp Interview Questions

Define multicast c# delegate?

0 Answers  


What is the difference between package and interface?

0 Answers   Hexaware,


Wcf and what is difference between wcf and web services?

0 Answers  


What is Garbage Collection in .Net?

0 Answers  


What all details the assembly manifest will contain?

0 Answers  






How long will it take to learn c#?

0 Answers  


What is virtual class in C#?

0 Answers   B-Ways TecnoSoft,


what is IFormatable

0 Answers   Wipro,


What are the advantages of generics in c#?

0 Answers  


what are some characteristics of an array?

0 Answers  


What is function and method in c#?

0 Answers  


Is type nullable c#?

0 Answers  


Categories