Here are some examples used to demonstrate the difference between the 2 properties :
I have a DataGrid as displayed below:
- This property is used to reference a selected DataGrid row.
- SelectedRow value is passed through if a user clicks on the row, which means that the SelectedRow property will not work unless it is assigned within a click event (such as Button click or Link click)
- Select a row in DataGrid.
- Click ‘Display Selected Row’ button.
- You will notice that the label has been populated with the SelectedRow.EmployeeID value.
Scenario 2: DataRow
- This property is used to reference a Text column in the current row of a DataGrid control.
- The DataRow property is available from within the DataGrid’s dropdown column.
- Since the value can be populated without a user action, it does not need to be assigned AND is unavailable within a click event.
- Add a Dropdown column in the DataGrid called ‘DataRow Value’
- Set the DataSource value as displayed. (Notice that the parameter is assigned to DataRow.EmployeeID)
No comments:
Post a Comment