Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Iterating through Repeater.Items

Reply
Thread Tools

Iterating through Repeater.Items

 
 
Mark Fox
Guest
Posts: n/a
 
      11-14-2003
Hello,

I have a repeater and in each itemtemplate I have a
radiobuttonlist. I am attempting to figure out how on
postback I could iterate through the rows displayed by
the repeater and for each row grab the selected value of
the radio button list. When is the Repeater.Items
collection populated? I first attempted to access the
Repeater.Items collection from the Command event of a
normal linkbutton on the page, but it was empty. Is it
not populated before the Command event of a linkbutton?
In the documentation for Repeater.Items, it accesses the
collection in the Repeater's ItemCommand event handler.
But when I moved the linkbutton into the FooterTemplate
of the Repeater, the itemcommand event handler isn't
being raised even though I wired it up in
InitializeComponent. Why might the ItemCommand not be
raised? If it's possible to access the Repeater.Items
collection outside the ItemCommand event handler, where
may I do so? Here is some of the code I'm using:

Code Behind:

private void InitializeComponent()
{
this.Load += new
System.EventHandler(this.Page_Load);

this.rpRegistrations.ItemDataBound += new
RepeaterItemEventHandler(rpRegistrations_ItemDataB ound);
this.rpRegistrations.ItemCommand
+= new RepeaterCommandEventHandler
(rpRegistrations_ItemCommand);

}


private void rpRegistrations_ItemCommand
(object source, RepeaterCommandEventArgs e)
{

// The if statement below never gets called
if(e.CommandName == "Update")
{
}
}

Web Form:

<asp:Repeater
ID="rpRegistrations" Runat="server">

<HeaderTemplate>
<table
border="0" cellpadding="0" cellspacing="0" width="100%">

<tr>

<td class="Bold">&nbsp;</td>

<td class="Bold">Name</td>
</tr>
</HeaderTemplate>

<ItemTemplate>

<tr>

<td class="Normal">

<asp:RadioButtonList ID="rblNumber"
Runat="server" CssClass="Normal"
RepeatDirection="Horizontal" Visible="False">

<asp:ListItem
Value="1">One</asp:ListItem>

<asp:ListItem Value="2"
Selected="True">Two<asp:ListItem>

</asp:RadioButtonList>

</td>

</tr>

</ItemTemplate>

<FooterTemplate>

</table>

<asp:LinkButton ID="btnUpdate"
CommandName="Update" Runat="server" Text="Save"
CssClass="Command" /><br>

</FooterTemplate>
</asp:Repeater>

 
Reply With Quote
 
 
 
 
Mark Fox
Guest
Posts: n/a
 
      11-14-2003
Hello,

I figured this out. I had EnableViewState=False.
My bad.


>-----Original Message-----
>Hello,
>
> I have a repeater and in each itemtemplate I have a
>radiobuttonlist. I am attempting to figure out how on
>postback I could iterate through the rows displayed by
>the repeater and for each row grab the selected value of
>the radio button list. When is the Repeater.Items
>collection populated? I first attempted to access the
>Repeater.Items collection from the Command event of a
>normal linkbutton on the page, but it was empty. Is it
>not populated before the Command event of a linkbutton?
>In the documentation for Repeater.Items, it accesses the
>collection in the Repeater's ItemCommand event handler.
>But when I moved the linkbutton into the FooterTemplate
>of the Repeater, the itemcommand event handler isn't
>being raised even though I wired it up in
>InitializeComponent. Why might the ItemCommand not be
>raised? If it's possible to access the Repeater.Items
>collection outside the ItemCommand event handler, where
>may I do so? Here is some of the code I'm using:
>
>Code Behind:
>
> private void InitializeComponent()
> {
> this.Load += new
>System.EventHandler(this.Page_Load);
>
> this.rpRegistrations.ItemDataBound += new
>RepeaterItemEventHandler(rpRegistrations_ItemData Bound);
> this.rpRegistrations.ItemCommand
>+= new RepeaterCommandEventHandler
>(rpRegistrations_ItemCommand);
>
> }
>
>
> private void rpRegistrations_ItemCommand
>(object source, RepeaterCommandEventArgs e)
> {
>
>// The if statement below never gets called
> if(e.CommandName == "Update")
> {
>}
>}
>
>Web Form:
>
> <asp:Repeater
>ID="rpRegistrations" Runat="server">
>
> <HeaderTemplate>
> <table
>border="0" cellpadding="0" cellspacing="0" width="100%">
>
> <tr>
>
> <td class="Bold"> </td>
>
> <td class="Bold">Name</td>
> </tr>
> </HeaderTemplate>
>
> <ItemTemplate>
>
> <tr>
>
> <td class="Normal">
>
> <asp:RadioButtonList ID="rblNumber"
>Runat="server" CssClass="Normal"
>RepeatDirection="Horizontal" Visible="False">
>
> <asp:ListItem
>Value="1">One</asp:ListItem>
>
> <asp:ListItem Value="2"
>Selected="True">Two<asp:ListItem>
>
> </asp:RadioButtonList>
>
> </td>
>
> </tr>
>
> </ItemTemplate>
>
> <FooterTemplate>
>
> </table>
>
> <asp:LinkButton ID="btnUpdate"
>CommandName="Update" Runat="server" Text="Save"
>CssClass="Command" /><br>
>
> </FooterTemplate>
> </asp:Repeater>
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iterating a std::vector vs iterating a std::map? carl C++ 5 11-25-2009 09:55 AM
Dynamically adding and iterating through webcontrols Dany P. Wu ASP .Net 6 09-10-2004 08:19 PM
Iterating through specific rows of DataReader... Jacko ASP .Net 8 10-23-2003 10:59 PM
Iterating through controls (VB) Jeremy ASP .Net 1 07-31-2003 04:27 PM
CheckBoxList -- Iterating Through Items Ron ASP .Net 0 07-15-2003 06:51 PM



Advertisments