what's the Difference between DataView and DataTable?
Answer Posted / 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 |
Post New Answer View All Answers
What is int32 in c#?
What is the difference between method parameters and method arguments. Give an example?
What is a private class in c#?
What is the difference between wrapper class and primitive?
What is the use of constructor in c# with example?
How do I download a program to my desktop?
What is private static in c#?
Wcf and what is difference between wcf and web services?
Why generics are used in c#?
Why interface is required?
What is the difference between finally and finalize block?
What is command object in c#?
What is difference between dynamic and var in c#?
What are different types of Delegates in C#?
What is difference between ienumerable and list in c#?