Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution 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 4th, 2005, 02:13 AM
Authorized User
 
Join Date: May 2005
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Default cant implicitly convert type int to bool

Hi Friends,
i would like your help as i am getting some problems with the following code.
i have marked the lines in red color.
please help me out.

private void btnauthor_Click(object sender, System.EventArgs e)
{
    int i;
    CheckBox cb;
    DataGridItem dgitem;
    for(i=0;dgemp.Items.Count-1;i++)
    {
         dgitem= dgemp.Items[i];
         cb=(CheckBox)(dgitem.FindControl("chk1"));
    }
    if(cb ="" && cb.Checked )
    {
        ordList += dgitem.Cells[1].Text + "";
    }
    lblexec.Text= KillEnding(ordList.Trim());
}

private string KillEnding(string sItem)
{
    return sItem.Substring(0,sItem.Length-1);
}



 
Old May 5th, 2005, 01:51 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Change dgemp.Items.Count-1 to i < dgemp.Items.Count-1

Brian
 
Old May 6th, 2005, 12:22 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 186
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This ia cross post of

http://p2p.wrox.com/topic.asp?TOPIC_ID=30084

 
Old November 19th, 2005, 04:57 PM
Registered User
 
Join Date: Nov 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it's much easier if you just use the foreach loop

foreach(DataGridItem dgItem in dgemp.Items)
{
     CheckBox cb = (CheckBox)dgItem.FindControl("chk1");
}





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
Cannot implicitly convert type int to bool muskaanbajaj General .NET 12 May 5th, 2005 03:57 AM
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.