Disclaimer: I am more of a back-end / wpf developer. There are probably more elegant solutions, but it seems to work.
Change your flag identifier so that it is not unique (sorry, this will break the w3c check) and install it on the runat server and set the CheckBox value for your Id data source:
<ItemTemplate>
<tr>
<td class="firstcol">
<label runat="server"><%# Eval( "Id" ) %></label>
<input id="MyCheckBox" value='<%# Eval("Id") %>'
type="checkbox" runat="server" />
</td>
</tr>
</ItemTemplate>
ListView CheckBoxes:
protected void btnDownload_Click( object sender, EventArgs e )
{
foreach( ListViewDataItem item in ListView1.Items )
{
var chk = item.FindControl( "MyCheckBox" ) as System.Web.UI.HtmlControls.HtmlInputCheckBox;
if( chk != null && chk.Checked )
{
string value = chk.Value;
}
}
}
Linq:
protected void btnDownload_Click( object sender, EventArgs e )
{
var checkedCheckBoxes = ListView1.Items.Select( x => x.FindControl( "MyCheckBox" ) as HtmlInputCheckBox )
.Where( x => x != null && x.Checked );
}