How do I reference a DataSource table in my display page?

tblDiesel is created in a code behind file - mypage.aspx.vb:
        dieselCommand.Fill(DS, "tblDiesel")
It's possible that the query will return an empty result set and I therefore assume that tblDiesel would not have any rows in it. Perform I process tblDiesel in the code behind file I test that the row count > 0.
If DS.Tables("tblDiesel").Rows.Count > 0 Then
   do something
End If

In the display page - mypage.aspx - I want to know the samething. VS 2008 doesn't like my If statement indicating "DS" is undeclared. Can someone please tell me what the proper syntax is for this?

Many Thanks!
Tim

<%  If DS.Tables("tblDiesel").Rows.Count > 0 Then%>
    <tr>
        <td colspan="8" class="modelTitle">Diesels</td>
    </tr>
<!-- #include virtual="/includes/vehicleSummaryHeader.aspx" -->
  <ASP:Repeater id="modelDieselRepeater" runat="server">
      <HeaderTemplate>
      </HeaderTemplate>

      <ItemTemplate>
            <asp:Repeater ID="dieselRepeater" runat="server"
                DataSource='<%# Container.DataItem.Row.GetChildRows("Diesel") %>'>
                <ItemTemplate>
<!-- #include virtual="/includes/vehicleSummary.aspx" -->
                </ItemTemplate>
            </asp:Repeater>

      </ItemTemplate>

  </ASP:Repeater>
<% End If%>
bigmoxyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Oliver AmayaEntrepeneurCommented:
Hi, you would have to do it in your code-behind, just set the repeater's visible property to false:
If DS.Tables("tblDiesel").Rows.Count > 0 Then
   modelDieselRepeater.visible = True
Else
  modelDieselRepeater.visible = False
End If

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.