C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » ASP.NET »

check box list selection


Posted Date: 24 Nov 2008      Posted By: sarayu      Member Level: Gold     Points: 1   Responses: 4



Hi all,

Here i am using below code for check box list control to append selected names in check box list.


string st = "";

foreach (ListItem li in Chkcounselor.Items)
{
if (li.Selected)
{
st += li.Value.ToString();
}
}

the above code is not getting values into string "st"

But the code is correct(i think)

When i check in debugging mode li.selected is showing false every time....

Please help me out...

thank you.....





Responses

Author: greeny_1984    24 Nov 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 0

did u select any value in checkbox

Regards,
Greeny_1984

Rate this Response[Excellent/Good/Poor]
FRESHERS check this link
Need help from me join here



Author: Syed Shakeer Hussain     24 Nov 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 2

hi...

use this code


if(checkbox1.checked)
{
strig str="YES"
}
else
{
string str2="No"
}


Thanks & Regards!
Syed Shakeer Hussain



Author: vipul    24 Nov 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 6

Hi,
string strItem = "";
int i = 0;
foreach (ListItem lstItem in chklistInterests.Items)
{
if (lstItem.Selected)
{
if (i == 0)
strItem += lstItem.Text.ToString();
else
strItem += " , " + lstItem.Text.ToString();

i++;
}
}
used this code or see you select any item or not or if you bind this list box at page load event so you put into the
if(!ispostbak)
{
//Bind list box
}

vipul,

Please Rate This Answer If They Helpful

Thanks & Regards
Patel Vipul



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : hi deepika haridasa
Previous : What is the query to enter system date and date after 3 months form the system date?
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use