Sunday, February 8, 2009

Data Binding in ASP.NET 3.5 [Part One]

Data Binding in ASP.NET 3.5 [Part One]

Question 1: What does the ConflictDetection property of the SqlDataSource control?

The ConflictDetection property allows us to ask the SqlDataSource control what kind of conflict detection to use when updating the bound data. This determines what action should be performed if more than one user attempt to edit or delete the same data.

There are two possible values for this property:

1) OverwriteChange: The data source control overwrites all values in a data row with its own values for the row.
2) CompareAllValues: The data source control employs the OldValues collection of the Update and Delete methods to determine whether the data has been changed by another process.

For more info click here.


Question 2: What does the Select property of the LinqDataSource control?

It can be used to control the selection of data from the context object. For example, in the following source:


<asp:LinqDataSource ID="LinqDataSource1" runat="server"
ContextTypeName="NorthwindDataContext"
TableName="Customers"<span >Select</span>="new (CustomerID, ContactName)">
</asp:LinqDataSource>


binding LinqDataSource1 to a GridView makes just the two specified fields be displayed. If no Select property is specified, the LinqDataSource control returns all the public properties exposed by the data object.

A side effect of using this property is that the resulting data source no longer supports the inserting, updating or deletion of data. So to limit the data shown by the bound control, we may consider specifying the fields in the bound list control rather than in the LinqDataSource control.


Original questions authored by G. R. Roosta

No comments:

Post a Comment