Ryan Chong
asked on
How to use LINQ to get selected items (checkboxes) within a GridView control that allow paging?
I'm exploring the possibility to use LINQ to get selected items (checkboxes) within a GridView control that allow paging.
Checkbox is added like this:
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chk" runat="server" />
</ItemTemplate>
</asp:TemplateField>
Anyone can advise here? Thanks
Checkbox is added like this:
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chk" runat="server" />
</ItemTemplate>
</asp:TemplateField>
Anyone can advise here? Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
(PS: there's also a LINQ zone, in case you want to make any follow-up questions....;-).
ASKER
Hi there,
Thanks for your codes, have some fun with it, and my final outcome is something like below:
var checkedIDs = from GridViewRow row in GridView1.Rows
where (row.FindControl("chk") as CheckBox).Checked
select (row.FindControl("id") as HiddenField).Value;
//....
cheers
Thanks for your codes, have some fun with it, and my final outcome is something like below:
var checkedIDs = from GridViewRow row in GridView1.Rows
where (row.FindControl("chk") as CheckBox).Checked
select (row.FindControl("id") as HiddenField).Value;
//....
cheers
Looks good. Tx for the grade! ;-)