Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 5th, 2005, 01:39 AM
Authorized User
 
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Friends,
i tried it with or operator also and now its giving the runtime error ie "object reference not set to an instance of the object".
cud u plz help me out.

 
Old May 5th, 2005, 02:08 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 186
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I agree with Peter, Please Look at the statements

cb ==null && cb.Checked

If the control is not there (null) how can you ever access the Checked property

IT Should be NOT EQUAL TO NULL


cb !=null && cb.Checked

Or

if(cb!=null)
{
    if(cb.Checked)
    {
    ...
    }
}


Prashant
 
Old May 5th, 2005, 03:57 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

                  
Code:
for(i=0;i<dgemp.Items.Count;i++)
Code:
                  {

                         dgitem= dgemp.Items[i];

                         cb=(dgitem.FindControl("chk1")) as CheckBox;

                  }

                  if(cb !=null && cb.Checked )    
                  {

                        ordList += dgitem.Cells[1].Text + "";

                  }

and this doesn't crash
Code:
if(cb ==null || !(cb.Checked) ){}
what is your logic?explain its scenario.

_____________
Mehdi.
software student.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot implicitly convert type ... lcarpay ASP.NET 2.0 Basics 3 June 22nd, 2007 11:20 PM
cant implicitly convert type int to bool muskaanbajaj BOOK: ASP.NET Website Programming Problem-Design-Solution 3 November 19th, 2005 04:57 PM
How to Convert a int in a bool with FormatStrings ShadowMoon Classic ASP Basics 2 October 26th, 2004 05:53 AM
Can't convert type 'bool' to 'int' Gjerstad BOOK: ASP.NET Website Programming Problem-Design-Solution 2 July 9th, 2003 10:33 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.