[Webinar] Streamline your web hosting managementRegister Today

x
  • 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!
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%>
0
bigmoxy
Asked:
bigmoxy
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
Else
  modelDieselRepeater.visible = False
End If

Open in new window

0

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