Bit confused about this. I was under the impression that if you added server controls to the ItemTemplate of a repeater then the ID's assigned to those controls would persist across postbacks and the state would be maintained. But it doesn't seem to be happening. Here's my ItemTemplate:
<asp:HiddenField ID="hidPending" runat="server" value="<%# DataBinder.Eval(Container.DataItem, "Id")%>" />
<td class="leftpadd"><uc:restrictedtext ID="uclblCategory" runat="server" Width="125" /></td>
<td style="border-left:1px solid #528ABD;" class="leftpadd"><%# DataBinder.Eval(Container.DataItem, "SelectedOptions")%></td>
<td style="border-left:1px solid #528ABD;" class="leftpadd"><%# DataBinder.Eval(Container.DataItem, "Price.IncludingTax", "{0:C}")%></td>
<td style="border-left:1px solid #528ABD;" class="leftpadd"><%# DataBinder.Eval(Container.DataItem, "ExtrasCost", "{0:C}")%></td>
<td style="border-left:1px solid #528ABD;" class="leftpadd"><%# DataBinder.Eval(Container.DataItem, "Quantity", "{0:000}")%></td>
<td style="border-left:1px solid #528ABD;" class="leftpadd"><asp:CheckBox ID="chkPendingItems" runat="server" /></td>
Which populates fine. What I'm looking to happen is for the user to be able to select certain items from the repeater using the checkbox and "process" them (i.e. perform some data operations on those items) on clicking a button which is outside the repeater. Here's my button click code:
Private Sub lnkPendingProcessSelected_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lnkPendingProcessSelected.Click
For Each rItem As RepeaterItem In rptPendingItems.Items
If rItem.ItemType = ListItemType.Item Or rItem.ItemType = ListItemType.AlternatingItem Then
Dim chk As CheckBox = DirectCast(rItem.FindControl("chkPendingItems"), CheckBox)
If chk.Checked Then
Dim orderItemId As Integer
Dim hid As HiddenField = DirectCast(rItem.FindControl("hidPending"), HiddenField)
orderItemId = CInt(hid.Value)
My.Application.ManagerFactory.OrderManagerInstance.ChangeOrderItemStatus(orderItemId, Concrete.Cms.DataTransferObjects.OrderItemStatus.Processing)
End If
End If
Next
End Sub
But if you step through this, the checkboxes are found and assigned correctly but their Checked attribute is always False. Anyone have any suggestions as to why state isn't being maintained and what I can do about it?