M
Mark Fox
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_ItemDataBound);
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>
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_ItemDataBound);
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>