I have this table with which I create dynamic checkboxes (the number of records may/will vary) the idea is that I can select a checkbox on whatever table row and “Send” those records.
I want to send an array of ID’s off to a different page for processing – but i’m very stuck!
Here is my table/form code
<form action="processingpage.aspx" method="post">
<asp:Repeater ID="GroupList" runat="server">
<HeaderTemplate>
<table id="grouptable" class="table">
<thead>
<tr>
<th>Broadcast</th>
<th>ID</th>
<th>Name</th>
<th>Last Modified</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<input type="checkbox" name="BroadcastSelect[]" value="<%# Eval("Group_ID") %>"</input></td>
<td><%# Eval("Group_ID") %></td>
<td><%# Eval("DESC") %></td>
<td><label id="test">hello</label></td>
<td><a class="btn btn-info" href="<%# Eval("gURL") %>">Edit</a>/td>
</tr>
</ItemTemplate>
<FooterTemplate>
</tbody>
</table>
</FooterTemplate>
</asp:Repeater>
<input class="btn primary" type="submit" value="Broadcast"/>
</form>
I think this is sending the array ok as I managed to see this via Request.in
BroadcastSelect[]TESTGROUP (which is one of the items I sent)
but on my receiving page I’m getting nothing but blank text I’ve tried
Label1.Text = Page.Request.Form["BroadcastSelect[0]"];
and
Label1.Text = Page.Request.QueryString["BroadcastSelect[0]"];
but no values are printed. Can anyone point me in the right direction?
I think the problem is that it is not possible to index the
<input name="BroadcastSelect[]">throughRequest.FormorRequest.QueryString.If you breakpoint in the code, you will see that the Request.Form object will have
Request.Form["BroadcastSelect[]"]as one of the available items, which will return a CSV list of values.So try using this instead…
Obviously the code in the block can also be brought down to a single line, but if you want something other than the 1st item, check that you’re not selected an “out of bound” index…