mardi 1 septembre 2020

How to show checked checkboxes in asp.net c#

I have some checkboxes which are dynamic.

Table for this is as follows:

     <table>
                      <tr>
                              <td style="width: 5%;" >
                              </td>
                              <td class="description" align="centre" id="tdEAlist">
                              </td>
                      </tr>
                 </table>

aspx: (for getting the chexboxes)

  $('#tdEAlist').html(AJAX.getExtraData('EAlist'));

Then at class level I am showing these checkboxes like this .

 ArrayList ExtdataExisting = new ArrayList();
            ExtdataExisting.Add("EAlist");
            ExtdataExisting.Add(createCheckBox(getDataTableFromQuery("select id,value,null as checked 
  from ChecklistOptionSetup where type in('1');"), "chkEAlist_", ""));
            retAry.Add(ExtdataExisting);

html for check boxes:

        Html.Append("<tbody>");
        Html.Append("<td width='10%' class=\"GreyBorder\" > " + SerialCount++ + "</td>");
        Html.Append("<td width='50%' class=\"GreyBorder\" >KYC Risk Category</td>");
        Html.Append("<td style=\"padding-left:8%\" id= 'tdEAlist' width='20%' class=\"GreyBorder\" >" 
       + Dt.Rows[0]["value"].ToString() + @"</td>");
        Html.Append("<td width='20%' class=\"GreyBorder\" ></td>");

In the third <td> , I am giving the id tdEAlist which is the id for checkboxes and they are shown as a table like

~Low
~Medium
~High

The checkboxes are being saved in the database correctly. However It does not show tick mark on those checkboxes that are saved as yes in the database. What do I need to do in order to show tick on checkboxes? I am a little confused. please help

I tried something like this

Html.Append("<td style=\"padding-left:8%\" id= 'tdEAlist' width='20%' class=\"GreyBorder\" >" + 
(Dt.Rows[0]["value"].ToString() == "Y" ? "checked='checked'" : "") + @"</td>");

But it made no difference.




Aucun commentaire:

Enregistrer un commentaire