locked
Checkbox RRS feed

  • Question

  • User245475216 posted

    Hi,

    I have 4 checkbox's displayed on a page. Depending on the selection, it should execute parameterized stored proc and stored proc takes 2 parameters - 2 sets from 4 checkboxes. So,  I am trying to figure out a better way of doing it. 

    So far, I tried - using for loop and capturing the values. Is there any better approach, please suggest. Thanks.

    Friday, September 28, 2018 7:06 PM

All replies

  • User475983607 posted

    What kind of application is this and is there anyway you can post the source code?

    Friday, September 28, 2018 8:02 PM
  • User245475216 posted

    This is a general asp.net web application. I am building the code, so its still in draft stage. I was looking for idea's to implement. So, the goal here is, capture 2 X 2 check box values and pass as parameters to the stored proc. So, ideally, it should generate 4 output's. 

    Sample - Capturing check box value to 4 different variables and doing a for loop 

    for (i.....)

       for (j....)

                 stored_proc call with params

    Friday, September 28, 2018 8:17 PM
  • User475983607 posted

    prasadbvm

    This is a general asp.net web application. I am building the code, so its still in draft stage. I was looking for idea's to implement. So, the goal here is, capture 2 X 2 check box values and pass as parameters to the stored proc. So, ideally, it should generate 4 output's. 

    Sample - Capturing check box value to 4 different variables and doing a for loop 

    for (i.....)

       for (j....)

                 stored_proc call with params

    An ASP.NET can be Web Forms, MVC, or Web API.  Which one are you building as fetching a checkbox is extremely simple and does not require a loop.  However, the syntax is different depending on the type of application you are building.

    It there any way you can post the source code including the procedure?  What is a 2x2 checkbox?  Can you post the markup that shows a 2x2 checkbox?  Do you mean the checkboxes are rendered dynamically?

    Friday, September 28, 2018 8:23 PM
  • User-271186128 posted

    Hi prasadbvm,

    Do you mean you are using a for loop to capture the checkbox value?

    As mgebhard said, if you could post the related code about the checkbox, it might be easier for us to help you solve the problem.

    Besides, it seems that your application is web form application, if that is the case, you could get the checkbox value based on the id property (using asp.net server control: add runat="server"). code as below:

     <asp:CheckBox ID="CheckBox1" runat="server" Text="AAA" />

    code behind:

            protected void btnAdd_Click(object sender, EventArgs e)
            {
                // to check whether the checkbox1 is checked or not
                if (CheckBox1.Checked)
                {
                   var str = CheckBox1.Text; //get the checkbox text value.
                }
            }

    Best regards,
    Dillion

    Monday, October 1, 2018 6:26 AM