5 Replies - 331 Views - Last Post: 07 May 2020 - 10:31 AM Rate Topic: -----

#1 DarenR   User is offline

  • D.I.C Lover

Reputation: 708
  • View blog
  • Posts: 4,580
  • Joined: 12-January 10

can you get the value of a check box with lambda

Posted 07 May 2020 - 06:59 AM

so if i have 2 check boxes -- can you get the value of the checked ones using lambda?

i cant seem to find any info on how to get the value for a singular check box -- all i am see are check box lists which i am not using.


thoughts?
Is This A Good Question/Topic? 0
  • +

Replies To: can you get the value of a check box with lambda

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15797
  • View blog
  • Posts: 63,297
  • Joined: 12-June 08

Re: can you get the value of a check box with lambda

Posted 07 May 2020 - 07:04 AM

Clarification - if you have two checkboxes wouldn't you have two specific IDs to just poll straight up? LINQ seems a little overkill.
Was This Post Helpful? 0
  • +
  • -

#3 DarenR   User is offline

  • D.I.C Lover

Reputation: 708
  • View blog
  • Posts: 4,580
  • Joined: 12-January 10

Re: can you get the value of a check box with lambda

Posted 07 May 2020 - 07:08 AM

yeah you are right -
Was This Post Helpful? 0
  • +
  • -

#4 h4nnib4l   User is offline

  • The Noid
  • member icon

Reputation: 1562
  • View blog
  • Posts: 2,195
  • Joined: 24-August 11

Re: can you get the value of a check box with lambda

Posted 07 May 2020 - 09:43 AM

What do you mean by value? Are you looking for the name, or the content of a label or textbox that the checkbox is associated with?
Was This Post Helpful? 0
  • +
  • -

#5 DarenR   User is offline

  • D.I.C Lover

Reputation: 708
  • View blog
  • Posts: 4,580
  • Joined: 12-January 10

Re: can you get the value of a check box with lambda

Posted 07 May 2020 - 10:02 AM

i was going to make a lambda that returned the value of the checked checkbox or return "" if not checked

since i only had 2 boxes i just used if statements
Was This Post Helpful? 0
  • +
  • -

#6 h4nnib4l   User is offline

  • The Noid
  • member icon

Reputation: 1562
  • View blog
  • Posts: 2,195
  • Joined: 24-August 11

Re: can you get the value of a check box with lambda

Posted 07 May 2020 - 10:31 AM

Well, in case you still want to solve it via lambda, how about something like this?

Page.Form.Controls.Where(c => c is CheckBox).Where(cb => cb.IsChecked).Select(cb.Value);


EDIT: Changed from c.Type is CheckBox to c is Checkbox

This post has been edited by h4nnib4l: 07 May 2020 - 01:57 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1