Click here to Skip to main content
15,899,124 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

i use check box list in which check several checkbox,
when i save record the it item.selected show false .

how to solve,
here is html code:-

XML
<asp:CheckBoxList ID="lstAccessories" runat="server" DataTextField="AccessoryCode"
                                                                DataValueField="AccessoryID" CellSpacing="5" CellPadding="30" RepeatLayout="Table"
                                                                RepeatColumns="3" Width="95%" RepeatDirection="Horizontal" >EnableViewState="false"
</asp:CheckBoxList&>

how to solve it 



here is codeBehind code:-



&lt;pre lang=&quot;vb&quot;&gt;Dim strAcc As String = String.Empty
               For Each item In lstAccessories.Items
                   Dim objCAccessory As New CAccessoryCodes
                   If item.Selected Then
                       objCAccessory.AccessoryID = item.value
                       &amp;#39;objCAccessory.AccessoryCode = objCAccessory.AccessoryCode + &amp;quot;,&amp;quot; + item.Text
                       objCAccessory.AccessoryCode = item.Text
                       If objCAccessory.AccessoryCode &amp;lt;&amp;gt; Nothing Then
                           strAcc = IIf(strAcc = String.Empty, objCAccessory.AccessoryCode, strAcc + &amp;quot;,&amp;quot; + objCAccessory.AccessoryCode)
                       End If

                       &amp;#39;If AccessoryCodes = &amp;quot;&amp;quot; Then
                       &amp;#39;    AccessoryCodes = item.value
                       &amp;#39;Else
                       &amp;#39;    AccessoryCodes = AccessoryCodes &amp;amp; &amp;quot;,&amp;quot; &amp;amp; item.value
                       &amp;#39;End If
                       &amp;#39;objCWOrder.objHandset.
                       objCWOrder.Accessories.Add(objCAccessory)
                   End If

               Next&lt;/pre&gt;</pre>
Posted

If you bind to your data source before running this code, it will reset all your selections.
 
Share this answer
 
Check in your pageload if you have put the checkboxlist databind code with Page.IsPostback condition.
Try:
VB
If (IsPostback)
  'checkboxlist databind code
End If
 
Share this answer
 
I didn't get you what you are talking about...
Please rewrite your question and mention clearly what exactly you need.

Sure I'll help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900