Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to a Bool to a System.GUID in C#

Posted on 2013-05-10
11
Medium Priority
?
465 Views
Last Modified: 2013-05-14
I need to convert a boolean value to a Guid using C#.
I get the below error message:
Cannot implicitly convert type 'bool' to 'System.Guid'

My code that caulse the error:
servicesupportrep.Value = chkShowServiceSupportRep.Checked;

Open in new window


Please help
0
Comment
Question by:newjeep19
[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
  • 6
  • 5
11 Comments
 
LVL 4

Expert Comment

by:bepsoccer1
ID: 39156717
what exactly are you trying to do that you are needing to convert bool (0|1) to GUID (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)?

Not knowing any more about your values here you could try something like:

servicesupportrep.Value = new Guid(chkShowServiceSupportRep.Checked.tostring());

Open in new window

0
 

Author Comment

by:newjeep19
ID: 39156807
Thank you for your reply. Below is the entire code:
private Lookup servicesupportrep = new Lookup();

////SET CHECKBOXES ON PAGE
  protected void Page_Load(object sender, EventArgs e)
        {
          chkShowServiceSupportRep.Checked = rpt_servicesupportrep.ToLower() == "true" ? true: ( rpt_servicesupportrep == "" ? false : true); 
        }
// FUNCTION saves the record 
        protected void saveReportSelections(string QuoteId)
        {
           servicesupportrep.Value = chkShowServiceSupportRep.Checked; // causing the error
         }

Open in new window

0
 
LVL 4

Expert Comment

by:bepsoccer1
ID: 39156833
So why is servicesupportrep.Value a GUID if you are trying to assign it as true or false?  GUID is Globaly Unique Identifier.  Are you saving this to a DB?  Should maybe change the data type for servicesupportrep or you are trying to set the wrong value.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:newjeep19
ID: 39156893
servicesupportrep is a lookup. Basically, when the checkbox is checked. Then the name in the lookup field is inserted into a ssrs report.
0
 
LVL 4

Expert Comment

by:bepsoccer1
ID: 39156923
Sounds more like you are wanting to do an If chkShowServiceSupportRep.Checked = 'true' then .....(write servicesupportrep.Value where ever it is you are writing it to.) or something like servicesupportrep.Value = chkShowServiceSupportRep.value?
0
 

Author Comment

by:newjeep19
ID: 39156941
I tried somthing like this but still get the same error:

 if (chkShowServiceSupportRep.Checked == true) { servicesupportrep.Value = true; } else { servicesupportrep.Value = false; }
0
 
LVL 4

Expert Comment

by:bepsoccer1
ID: 39156978
Then what ever servicessupportrep needs to be created as a boolean not a GUID.  Or you need to be setting a different field associated to the "servicesupportrep" record, which is a guid, like "enabled", which would be boolean.  Data would look like this in a table.

servicesupportrep      enabled      Name
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx      TRUE      Someone
yyyyyyyy-xxxx-xxxx-xxxx-xxxxxxxxxxxx      FALSE      SomeoneElse
0
 

Author Comment

by:newjeep19
ID: 39156990
OK I gotcha....so, I would need to get the Guid of the person whom is on the lookup field and then if there is a Guid (name) there then true else false....correct?
0
 
LVL 4

Expert Comment

by:bepsoccer1
ID: 39157011
If checkbox is check then insert name associated with the GUID in the lookup should be inserted into the report?
0
 

Author Comment

by:newjeep19
ID: 39157028
Correct?

if (chkShowServiceSupportRep.Checked == true)
            {
                LookupName(Guid)  =  servicesupportrep.Value;
            }
            else
            {

            }

Open in new window

0
 
LVL 4

Accepted Solution

by:
bepsoccer1 earned 1000 total points
ID: 39157079
possibly servicesupportrep.Value = LookupName(Guid)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

604 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