Link to home
Start Free TrialLog in
Avatar of M.L. Martin
M.L. MartinFlag for United States of America

asked on

Hide server controls if SQLDatasource empty or NULL

For a very long time I have tried to figure out how to hide a control like a asp textbox or asp dropdownlist if a sqldatasource is or is not a certain value. I want to do this without using asp.net server controls like gridview, detailview, datalist..etc. I simply want to do something like hide a control if the sqldatasource = 0 or no data return.

The following is as far as I have gotten but I need help. I am not even sure if this is correct.

Protected Sub StepDataShowArticle_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles StepDataShowArticle.Selecting
       
  End Sub

StepDataShowArticle would be the sqldatasource.

I am not very good at coding and if you can help me please provide a full sample. I appreciate the effort but sending me to yet another link will not help me very much. Thank you in advance.
ASKER CERTIFIED SOLUTION
Avatar of Camillia
Camillia
Flag of United States of America 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 M.L. Martin

ASKER

That's all the code this hack could come up with Lol! I'm sure it's what I'm looking for but I don't know where or how to write the code correctly. I will google .count==0 to see what I can find.
Would I do something like this? I'm really not sure of the syntax.

Protected Sub StepDataShowArticle_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles StepDataShowArticle.Selecting
       
If StepDataShowSArticle.Count == 0
    newsarticles.visible = False
  Else news articles.visible = True
End If
 
End Sub
What is your code in aspx page?
SOLUTION
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
SOLUTION
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