0

I have an ASP.Net Repeater I want to use to show From and Text from a dataset and I want to add it programmically. I have all the data in a dataset and can use that and I have verified the correct number for datarows when it loads so the data is their it is just not showing. What have I missed?.

Dim data As New Data
Dim ds As New DataSet
ds = data.LOADALL()
Dim drMsg() As DataRow = ds.Tables("MESSAGESYSTEM").Select("TOID='101'")
repeatMessages.DatagSource = drMsg

Now on the html side I have:

<asp:Repeater ID="repeatMessages" runat="server" >
    <HeaderTemplate>
              <table>
              <tr>
                 <th>From</th>
                 <th>Sublect</th>
              </tr>
          </HeaderTemplate>
          <ItemTemplate>
          <tr>
              <td bgcolor="#CCFFCC">
                    <asp:Label runat="server" ID="Label1" text='<%# Eval("FROMID") %>' />
              </td>
              <td bgcolor="#CCFFCC">
                  <asp:Label runat="server" ID="Label2" text='<%# Eval("MESSAGETEXT") %>' />
              </td>
          </tr>
          </ItemTemplate>
          <FooterTemplate>
              </table>
          </FooterTemplate>
    </asp:Repeater>

How can I fix this code to show the data in the Message table?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
JPJedi
  • 1,498
  • 7
  • 32
  • 58
  • 1
    You should show us the `LOADALL`-function. Does the table contain the columns `FROMID` and `MESSAGETEXT`? Besides you have a typo: `repeatMessages.DatagSource = drMsg`, that would not even compile. I'm also missing the `repeatMessages.DataBind`. Are you doing this only `If Not Page.IsPostBack` what would be correct? – Tim Schmelter Jul 03 '11 at 21:55
  • Yes the data is being loaded by the load function. their are 2 rows that are returned and they do have those column names. And yes this occurs withing a If not postback clause. – JPJedi Jul 03 '11 at 22:04
  • 2
    As @Tim is saying, call `repeatMessages.DataBind()` after assigning the data source. – Magnus Jul 03 '11 at 22:26
  • @JPJedi try to add the repeatMessages.DataBind(); – Aristos Jul 03 '11 at 22:27

1 Answers1

3

Try calling repeatMessages.DataBind(). All you are doing is assigning the source but you haven't told the program to do something with the data.

brenjt
  • 15,997
  • 13
  • 77
  • 118