Product Bundles
DevCraft
All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:
Web
Mobile
Document Management
Desktop
Reporting
Testing & Mocking
CMS
UI/UX Tools
Debugging
Free Tools
Support and Learning
Productivity and Design Tools
protected
void
RadImageGallery1_DataBound(
object
sender, EventArgs e)
{
SqlConnection connection=
new
SqlConnection(ConfigurationManager.ConnectionStrings[
"NorthwindConnectionString"
].ConnectionString);
connection.Open();
SqlCommand cmd =
SqlCommand(
"SELECT COUNT(*) FROM Images"
, cn);
Int32 count = (Int32)cmd.ExecuteScalar();
if
(count == 0)
RadImageGallery1.Visible =
false
;
connection.close();
}
Hi Marty,
You can databind the control manually - perform a Select() to see what the result is: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.sqldatasource.select(v=vs.110).aspx. If there is data - set the collection you have to the DataSource property and call the DataBind() method. Otherwise, set the Visible property to false.
You can also use the Selecting SqlDataSource event to see this information, as discussed in numerous placed in the net, e.g.: http://stackoverflow.com/questions/2231273/how-do-i-check-that-a-sqldatasource-returned-data. Regards,
Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.