Tutorials and code for ASP.NET 2.0,C#,SQL Server,AJAX tutorials,jQuery  
Home    Articles    Contact Us
 

ASP.NET
AJAX
Interview Questions
Sql Server
Technology News
Tips and Tricks
jQuery

 

Get Number of rows affected by SqlDataSource


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



User Comments:

Comment By fgxgbsdfg on 11/24/2009

uiftui iui


Post Your Comment :


Name
Email:
Comment:

Home | Contact Us

© 2008-09 TechnoReader.com. All rights reserved.