How to checked the previous record of check box?

Discussion in 'C#' started by haan86, Sep 17, 2009.

  1. #1
    hi...
    I have 5 check box here..
    For exampe: a, b, c, d, e
    When I tick for a and b,the detail then will send to database.
    If I want to update the check box, how to make the previous record, the check box of a and b are checked?

    Thanks lots... :)
     
    haan86, Sep 17, 2009 IP
  2. camjohnson95

    camjohnson95 Active Member

    Messages:
    737
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    You just need to retrieve the data from the database for that user and set the values to checked when the page is executed. it depends on how the values are saved to the database but basically something like:
    
    <%
    For i = 1 to NumberOfCheckBoxes
    %>
    <input type="checkbox" id="checkbox<%=i%>" checked="<%=isChecked(i)%>" />
    <% Next %>
    
    Code (markup):
    function isChecked(i) should check the database values and return a true or false String accordingly.
     
    camjohnson95, Sep 18, 2009 IP
  3. rahulwb

    rahulwb Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    if (chbox.selectedIndex = "Nameofcheckbox")
    {
    string mess = "Selected";
    }
     
    rahulwb, Oct 5, 2009 IP