Click here to Skip to main content
16,007,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,
I have a Gridview with a checkbox.The Grid is loaded based on values of two dropdownlist. The values in a dropdownlist is loaded based on web services.

Now my problem is when the checkbox is selected the page is refreshed and the values in dropdownlist will be set to default.That is, in any case when the page is refreshed the dropdownlists value is set to default. Only the dropdownlists value is changed,other fields value remains the same.I tried using updatepanel but it didn't work.

Any help will be really appreciated.

What I have tried:

<td>
                                   <asp:DropDownList ID="ddl_Prov" CssClass="txtboxAll"   Width="260px" runat="server" ></asp:DropDownList>
                                                  <asp:CascadingDropDown ID="CascadingDropDown1" runat="server" Category="facil" TargetControlID="ddl_Prov" PromptText="[Select Group]" LoadingText="Loading  Group..." ServicePath="~/Services/eservice.asmx" ServiceMethod="GetDropDownProgroup">
                                                  </asp:CascadingDropDown>

                                </td>



<td>
                                     <asp:DropDownList ID="ddl_Pro" CssClass="txtboxAll"   Width="260px" runat="server" ></asp:DropDownList>
                                                    <asp:CascadingDropDown ID="cdd_fa" runat="server" Category="facility"  ParentControlID="ddl_Pro" TargetControlID="ddl_Pr" PromptText="[Select Pr]" LoadingText="Loading Provider..." ServicePath="~/Services/Freservice.asmx" ServiceMethod="GetDropDownFacilitybyGr">
                                                    </asp:CascadingDropDown> 
                                  
                                  </td>


<asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="3%">
                                        <HeaderTemplate>
                                        <asp:CheckBox ID="chk_All" runat="server" AutoPostBack="True" oncheckedchanged="chk_All_CheckedChanged"  />
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                        <asp:CheckBox ID="chk_select" OnCheckedChanged="chk_select_CheckedChanged" AutoPostBack="True" runat="server"  />
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" Width="3%" />
                                        </asp:TemplateField>
Posted
Comments
F-ES Sitecore 17-Nov-17 5:51am    
You normally get this issue if you are binding your data on every postback rather than just the initial page view. If your code-behind looks like

Page_Load()
{
// bind data
}

change it to

Page_Load()
{
if (!Page.IsPostBack)
{
// bind data
}
}

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