aspx_professional thread: The .item[i].Selected property of a DATABOUND checkboxlist. HELP
Hi Robert
Thanks a lot. I realised shortly after i posted my error. I thought i was
back in old days of vb6 for a moment i guess!!
ben
>From: Robert Seber <robert.seber@n...>
>Reply-To: "ASPX_Professional" <aspx_professional@p...>
>To: "ASPX_Professional" <aspx_professional@p...>
>Subject: [aspx_professional] RE: The .item[i].Selected property of a DATAB
> OUND checkboxlist. HELP
>Date: Fri, 10 Aug 2001 06:25:43 +0100
>
>Classic error:
>
>
>for (int i=0; i< Keywords.Items.Count; i++) {
> if (Keywords.Items[i].Selected = true){
> //DO STUFF
> }
>}
>
>
>you are assigning true to the Selected property (single equals) rather than
>evaluating a boolean statement.
>
>Try this (double equals):
>
>
>for (int i=0; i< Keywords.Items.Count; i++) {
> if (Keywords.Items[i].Selected == true){
> //DO STUFF
> }
>}
>
>
>Rob.
>
>
>-----Original Message-----
>From: visual_ben@h... [mailto:visual_ben@h...]
>Sent: Thursday, August 09, 2001 11:10 PM
>To: ASPX_Professional
>Subject: [aspx_professional] The .item[i].Selected property of a
>DATABOUND checkboxlist. HELP
>
>
>Hi there
>
>I am going round incircles trying to solve this problem
>
>i have a databound checkboxlist which works fine.
>
>the problem is when i manipulate the checkboxes and post them back to the
>server for some reason checkboxlist1.Item[i].Selected returns true even if
>the item has not been checked.
>
>I can't figure out why and it is driving me crazy!!! I am sure there is
>nothing more i can do
>
>here is the code below
>
>the aspx page looks like this
>
><form runat="server">
><asp:checkboxlist id="Keywords"
>runat="server"
>RepeatLayout="Table"
>RepeatColumns="4"
>DataValueField="keyword_id"
>DataTextField="keyword_name"
>DataValueSelected=1
> />
><asp:TextBox id="uid"
>AutoPostBack="True"
> Visible="False"
> runat="server"/>
><asp:TextBox id="tt"
>AutoPostBack="False"
> Visible="False"
> runat="server"/>
><br>
><asp:Button id="Publish"
> Text="Assign keywords and publish document"
> OnClick="AssignPublish"
> runat="server" autopostback="True"/>
> </form>
>
>the data bound control binds correctly on page load
>
>then when i post to the function
>the codebehind looks like this
>
>public void AssignPublish(Object src, EventArgs E) {
>
>for (int i=0; i< Keywords.Items.Count; i++) {
> if (Keywords.Items[i].Selected = true){
> //DO STUFF
> }
>}
>
>Keywords.Items[i].Selected always equals true even if the item has not
>been selected
>
>please help!!!
>
>ben
>