We help IT Professionals succeed at work.

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

bigmoxy asked
Medium Priority
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!

<%  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%>
Watch Question

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

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