Tuesday, April 26, 2011

DataRowView Class

"DataRowView Class (System.Data)" ( http://bit.ly/dLuGGk )

Represents a customized view of a DataRow.

Here's a kitteh to relax you...

 Back to the story!

For instance, in the RowDataBound event of a GridView, where a single row/record of data is bound,  we can create a view of the data on the row by declaring a DataRowView object & assigning the DataItem property of the row to that object. From there, we are free to pick out the items on the row that are of interest to us.

' Get a view of the data bound to the current row.
Dim drvCurrentDataRow As DataRowView = e.Row.DataItem
' Get the price field from the row.
 Dim decPrice As Decimal = drvCurrentDataRow("Price")
 ' Get the quantity field from the row.
 Dim intQuantity As Integer = drvCurrentDataRow("Quantity")

No comments:

Post a Comment