Skip to main content
Participant
January 17, 2008
Question

ASP.Net C# Accessing MM:DataSet via code inside a Repeater

  • January 17, 2008
  • 1 reply
  • 412 views
Trying to acessing MM:DataSet via code inside a Repeater, but I'm only getting problems and errors when I'm attempting to do this.

I cannot seem to access the current item it is making, i need to do some number comparison in each item to determine if there is any problems with it.

Thanks for any help!
This topic has been closed for replies.

1 reply

Inspiring
January 17, 2008
"Nightw" <webforumsuser@macromedia.com> wrote in message
news:fmnnqs$f9i$1@forums.macromedia.com...
> Trying to acessing MM:DataSet via code inside a Repeater, but I'm only
> getting
> problems and errors when I'm attempting to do this.
>
> I cannot seem to access the current item it is making, i need to do some
> number comparison in each item to determine if there is any problems with
> it.
>
> Thanks for any help!
>
> <ASP:Repeater id="repeatMain" runat="server" DataSource='<%#
> dsTest.DefaultView %>'>
> <ItemTemplate>
> <%
> string sSomething = dsTest.FieldValue("Field", Container);
> sSomething += " added text";
> %>
> <tr>
> <td><%=sSomething%></td>
> </tr>
> </ItemTemplate>
> </ASP:Repeater>
>

You can use the ItemDataBound event of the repeater control to evaluate the
item after it has received data
http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.repeater.itemdatabound.aspx

<script language="C#" runat="server">
void repeatMain_ItemCreated(Object Sender, RepeaterItemEventArgs e) {
// access the dataRow to which the item is bound
DataRow theDataRow = (DataRow)e.Item.DataItem;

//Add a literalcontrol with the added text
switch (e.Item.ItemType) {
case ListItemType.Item:
case ListItemType.AlternatingItem:
e.Item.Controls.Add(new LiteralControl(" added text"));
break;
}
}
</script>