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


Please Help Members By Posting Answers For Below Questions

Explain more on CLR

755


What is the difference between int and int in c#?

497


What is tuple in c#?

534


Why does my windows application pop up a console window every time I run it?

528


What is function and method in c#?

515






Why do I get a syntax error when trying to declare a variable called checked?

554


what is the default access for a class

582


Why reflection is used in c#?

498


What is the namespace for datatable in c#?

500


How big is a 64 bit integer?

511


What is a thread c#?

503


What are the advantages of interface in c#?

504


What is the difference between out and ref in c#?

489


What do u mean by delegation?

541


How do you remove white spaces from a string?

499