troubleshooting Question

checkbox control parameter not working all the time

Avatar of louise_8
louise_8 asked on
ASP.NET
5 Comments1 Solution548 ViewsLast Modified:
Hi,

Im having an issue with a checkbox control parameter.
It seems to be ok when the page first runs (checked - value A)
 but once its unchecked it keeps that value..

When the page loads, the checkbox is selected
(I assign it to a page parameter, hdActiveGroups)  and the value relating to it 'A' is sent to the datasource correctly
Once I uncheck it, it correctly sends Z to the datasource.
Then when I check it again (value A) it seems to send value Z to the datasource.. ie I get results as if Z was passed (unchecked)

(even though hdActiveGroups  displays as A..)

Realistically I just need a way for the checkbox parameter to be A if checked, Z if unchecked and for it refresh the ddl when checkchanged

code:

   <asp:textbox ID="hdActiveGroups" runat="server" />
<asp:CheckBox ID="chkActiveGroups" runat="server" Checked="true" OnCheckedChanged="Check_GroupStatus" AutoPostBack="true"/>
 <asp:SqlDataSource ID="SqlDataSourceGroupDisc" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="aspGetDGroups" SelectCommandType="StoredProcedure">
            <SelectParameters>
               <asp:QueryStringParameter DefaultValue="123" Name="iClientid" QueryStringField="iClientid"  Type="Int32" />                    
                <asp:Parameter DefaultValue="0" Name="iGroupDiscountid" Type="Int32" />
                  <asp:ControlParameter ControlID="hdActiveGroups" Name="cStatus"  Type="String" />
            </SelectParameters>

codebehind

        </asp:SqlDataSource>

protected void Page_Load(object sender, EventArgs e)
    {
   
        if (chkActiveGroups.Checked)
        {
            hdActiveGroups.Text = "A";
        }
        else
        {
            hdActiveGroups.Text = "Z";
        }
etc
}

 protected void Check_GroupStatus(Object sender, EventArgs e)
    {

        if (chkActiveGroups.Checked)
        {
            hdActiveGroups.Text = "A";
        }
        else
        {
            hdActiveGroups.Text = "Z";
        }
       
        ddlGroupDiscount.DataBind();
    }
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros