[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 151
  • Last Modified:

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!

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

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


<% End If%>
1 Solution
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
  modelDieselRepeater.visible = False
End If

Open in new window


Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now