Bill Crawley
September 19th, 2007, 12:46 PM
Hi All,
Im using a Repeater with the following declaration:
<tbody>
<asp:Repeater ID="rptStarItems" runat="server">
<ItemTemplate>
<tr style="color: #284775; background-color: White;">
<td><asp:CheckBox ID="ChkSelected" runat="server" /></td>
<td ><asp:Label ID="lblId" runat="server" Text='<% #Eval("id") %>'></asp:Label></td>
<td ><%#Eval("name")%></td>
<td><%#Eval("subcomponent")%> </td>
<td><%#Eval("quantity")%></td>
<td><%#Eval("cost")%></td>
<td><%#Eval("unit")%></td>
<td><%#Eval("Description")%></td>
</tr>
</ItemTemplate>
As you can see this is in a table which is on an <asp:Panel.
Behind the code when the user has pressed a button, I'm trying to find which checkboxes the user has checked with the following:
For i = 0 To rptStarItems.Items.Count - 1
If DirectCast(((rptStarItems.Controls(i).FindControl("ChkSelected"))), CheckBox).Checked = True Then
'Do some stuff
............
However, my Directcast always returns false suggesting that its not finding the checkbox. I also tried cType, but that didn't make any difference either.
Im using a Repeater with the following declaration:
<tbody>
<asp:Repeater ID="rptStarItems" runat="server">
<ItemTemplate>
<tr style="color: #284775; background-color: White;">
<td><asp:CheckBox ID="ChkSelected" runat="server" /></td>
<td ><asp:Label ID="lblId" runat="server" Text='<% #Eval("id") %>'></asp:Label></td>
<td ><%#Eval("name")%></td>
<td><%#Eval("subcomponent")%> </td>
<td><%#Eval("quantity")%></td>
<td><%#Eval("cost")%></td>
<td><%#Eval("unit")%></td>
<td><%#Eval("Description")%></td>
</tr>
</ItemTemplate>
As you can see this is in a table which is on an <asp:Panel.
Behind the code when the user has pressed a button, I'm trying to find which checkboxes the user has checked with the following:
For i = 0 To rptStarItems.Items.Count - 1
If DirectCast(((rptStarItems.Controls(i).FindControl("ChkSelected"))), CheckBox).Checked = True Then
'Do some stuff
............
However, my Directcast always returns false suggesting that its not finding the checkbox. I also tried cType, but that didn't make any difference either.