what's the Difference between DataView and DataTable?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
Answer / ajay
DataTable: Represents one table in-memory
select distinct field from the filtered dataview
Is This Answer Correct ? | 9 Yes | 4 No |
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 |
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 |
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 |
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 |
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 |
What are the different types of constructors in c#?
What is xaml file in c#?
what are the different ways to cleaning up objects?
What is type safe code?
List down the reason behind the usage of c# language.
What is overriding in c#?
What is extended method in c#
Difference between a sub and a function in c#.
How do you declare an arraylist?
How do you create partial methods?
What is assembly manifest?
What is the difference between // comments, /* */ comments and /// comments?