Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion 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 August 12th, 2011, 01:40 AM
Authorized User
 
Join Date: Aug 2011
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Smile Asp:CheckBoxList Issue

Hi,

I have a checkboxlist like this -:
<asp:CheckBoxList ID="chk_UserRole" runat="server" RepeatDirection="Horizontal">
<asp:ListItem>1</asp:ListItem>
<asp:ListItem>2</asp:ListItem>
<asp:ListItem>3</asp:ListItem>
<asp:ListItem>4</asp:ListItem>

Now in the run time i want at least two of them wud be checked or ticked or selected...
I am writing this code
chk_UserRole.SelectedValue ="1";
chk_UserRole.SelectedValue = "2";

But it is showing only checkbox no 2 as checked.....
Cant we get more than one checkbox to be checked????

Thanks
Emma
 
Old August 12th, 2011, 03:49 AM
Authorized User
 
Join Date: Aug 2011
Posts: 14
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I got the solution....
ListItem li = chk_UserRole.Items.FindByValue("1");
li.Selected = true;
li = chk_UserRole.Items.FindByValue("2");
li.Selected = true;

....................





Similar Threads
Thread Thread Starter Forum Replies Last Post
CheckBoxList 123mehran ASP.NET 4 General Discussion 1 March 14th, 2011 06:09 PM
i e 6 issue with asp.net 1.1 rsanuj ASP.NET 1.x and 2.0 Application Design 0 August 26th, 2008 08:28 AM
asp:menu issue Russel ASP.NET 2.0 Professional 2 December 4th, 2006 03:27 PM
CheckBoxList stu9820 ASP.NET 1.0 and 1.1 Basics 10 May 25th, 2006 08:15 PM
Timer issue in ASP chmosiii Classic ASP Professional 10 January 31st, 2005 01:00 PM





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