Click here to Skip to main content
15,907,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I have created a web user control for multi check drop down list.
Here is code snippet:
<asp:TextBox ID="txtCombo" runat="server" ReadOnly="true" Text="--Select--" CssClass="DropDownCss" BackColor="#EEEEEE" Width="225" Height="25" ></asp:TextBox>
<cc1:PopupControlExtender ID="PopupControlExtender111"  runat="server" 
    TargetControlID="txtCombo" PopupControlID="Panel111" Position="Bottom" >

<input type="hidden" name="hidVal" id="hidVal" runat="server" />

<asp:Panel ID="Panel111" runat="server"  Width="230" BackColor="#EEEEEE" BorderColor="Gray" BorderWidth="1">
    <asp:CheckBoxList ID="chkList" 
        Height="150" onclick="CheckItem(this)">                                                                                                                                                                        

The control is getting bind and showing values but when page is getting postback the control is getting reinitialize.

How to keep current selected values even if page is postback.

Please suggest

Thanks and Regards,

1 solution

Loading of your checklist should check Page.isPostBack property and it not PostBack then load it.

// load your checklist
Share this answer
Avinash6474 19-Feb-15 6:24am    
Thanks for your immediate response..
The value loaded in this control are dependent on another drop down selected value. So on dropDown1_selectedIndexChange the values are bind with dropDowncheckListBox.

Now when there is any action happening on page ex: any other drop down selection the page is getting post back and value resetting.
John C Rayan 19-Feb-15 6:34am    
wherever you load your values , do the postback check and you will be fine.
Avinash6474 19-Feb-15 7:30am    
I got your point.
Thank you so much :)
John C Rayan 19-Feb-15 7:46am    
Glad I could help you. Please mark the solution as accepted if you haven't already done so.

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