Link to home
Start Free TrialLog in
Avatar of Shiva-Kumar
Shiva-Kumar

asked on

how to check if datasource is empty before binding it to gridview in asp.net

Hi

I am using the following code to get the data from database and bind it to gridview.

dim  mySqlString = "Select columname from table where xyz = 1"
Me.Gridview1.DataSource = CType(DataProvider.Instance().ExecuteSQL(mySqlString.ToString(), myParam), IDataReader)
Me.Gridview1.DataBind()

How can check if the query returned no rows before binding it to database.

Thanks



Avatar of Deathrace
Deathrace
Flag of India image

try to use a datareader, before binding the datasource of gridview1,hope the below might might give some hint for you.
http://www.adefwebserver.com/DotNetNukeHELP/Misc/code/DynamicForms_DynamicForms_DAL.vb.htm
ASKER CERTIFIED SOLUTION
Avatar of M3mph15
M3mph15
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Shiva-Kumar
Shiva-Kumar

ASKER

Thanks that worked.