Thursday 2 March 2017

How to set multiple Checked in CheckBoxList in asp.net



///   C#

    public void Set_CheckBoxList_Values(CheckBoxList cbl, string[] values)
    {
        foreach (ListItem item in cbl.Items)
        {
            item.Selected = values.Contains(item.Value);
        }
     }

/// Call 

string[] Partner = Convert.ToString(dtvp_A.Rows[0]["PartnerName"]).Split(',');
SetCheckBoxListValues(CBL_aNamePartner, Partner);

   

/// Result


No comments:

Post a Comment

Excel Sort values in ascending order using function TEXTJOIN

 Excel ::  Text ::  1,3,5,2,9,5,11 Result :: 1,2,3,5,5,9,11 Formula ::     TEXTJOIN ( ",",1,SORT(MID(SUBSTITUTE( A1 ,","...