locked
Check HtmlInpiut Checkbox conditionally inside Listview RRS feed

  • Question

  • User1126057398 posted

    How can on Check HtmlInpiut Checkbox conditionally inside Listview?

    Saturday, March 14, 2020 9:34 AM

Answers

  • User1126057398 posted

    Done it like below:

    <td>
    <input type="checkbox" id="cbAllTaken" name="foodselcd" <%#Convert.ToBoolean(Eval("isChecked")) ? "checked" : "" %> class="allTaken" Value='<%# Eval("Code") %>' onclick="cMealsTaken(this.checked,this.value)"/>
    </td>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 14, 2020 9:57 AM

All replies

  • User1126057398 posted

    Done it like below:

    <td>
    <input type="checkbox" id="cbAllTaken" name="foodselcd" <%#Convert.ToBoolean(Eval("isChecked")) ? "checked" : "" %> class="allTaken" Value='<%# Eval("Code") %>' onclick="cMealsTaken(this.checked,this.value)"/>
    </td>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, March 14, 2020 9:57 AM
  • User475983607 posted

    geetasks

    How can on Check HtmlInpiut Checkbox conditionally inside Listview?

    It's practically impossible to answer questions about code without the actual code.  The HTML form inputs follow standards that have been around for long long time.  I think you'll be interesting in learning the fundamentals; https://www.w3schools.com/html/html_forms.asp

    To answer your question, read the input parameter by name from the Request object.  The browser only sends the check inputs that are checked.

        <asp:ListView ID="ListView1" runat="server">
            <ItemTemplate>
                <input id="Checkbox1" type="checkbox" name="checkbox" value="check" />
            </ItemTemplate>
        </asp:ListView>
    string checkboxitems = Request["checkbox"];

    Most likely, you should use a standard ASP.NET checkbox server control.

    Saturday, March 14, 2020 10:34 AM