Get Number of rows affected by SqlDataSource / ObjectDataSource select Query
For SqlDataSource
To find out number of rows affected or returned by SqlDataSource select Query for that create event handler for 'Selected' event of the SqlDataSource control.Then,use 'AffectedRows' property of the SqlDataSource 'e' parameter to get of the number of records affected by the SqlDataSource.
Protected Sub SqlDataSource1_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs)Handles SqlDataSource1.Selected
lblRecordCount.Text = "No of Records : " & e.AffectedRows
End Sub
For ObjectDataSource
In ObjectDataSource data returned in dataset or datareader so for that use below code.
Protected Sub ObjectDataSource1_Selected(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs)Handles ObjectDataSource1.Selected
dsCount = New DataSet()
dsCount = e.ReturnValue
lblRecordCount.Text = "No Of Records : " & dsCount.Tables(0).Rows.Count.ToString()
End Sub