Solved

LINQ query problem, Please help.

Posted on 2008-09-29
2
202 Views
Last Modified: 2013-11-08
Hi,  
    I am trying to find all the check box that are checked on a html form in an asp.net page using LINQ query and I am having some problem. I am not sure what I am doing wrong.

IEnumerable<string>  cbChecked = Request.Form.Cast<string>().Where(c => c.Contains("cb_"));

I checked the form and it contains all the check boxes check.

Thanks
0
Comment
Question by:halaharr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
johnaryan earned 500 total points
ID: 22601264
Have you tried:
var cbChecked = Request.Form.OfType<CheckBox>().Select(c => c.Checked);
0
 
LVL 1

Author Closing Comment

by:halaharr
ID: 31501291
Correct solution was
IEnumerable  cbChecked = Request.Form.OfType().Where(c => c.Contains("cb_"));

But it helped me to to think that option.

Thanks
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question