We help IT Professionals succeed at work.

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

bigmoxy
bigmoxy asked
on
Medium Priority
163 Views
Last Modified: 2010-04-23
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%>
Comment
Watch Question

Entrepeneur
Commented:
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

Explore More ContentExplore courses, solutions, and other research materials related to this topic.