Exemple #1
0
 /// <summary>
 /// Developed By Malang Raja T
 /// </summary>
 /// <param name="c">Only Data Bound Controls eg.DropDownList,RadioButtonList,CheckBoxList </param>
 /// <param name="selectedValue"></param>
 /// <param name="selectedText"></param>
 /// <param name="type">0 - Index; 1 - Text; 2 - Value;</param>
 private void SelectDataBound(Control c, string selectedValue, string selectedText)
 {
     try
     {
         bool isDataBoundControl = false;
         if (c is DataBoundControl)
         {
             if (c is CheckBoxList || c is DropDownList || c is RadioButtonList)
             {
                 isDataBoundControl = true;
             }
             if (isDataBoundControl)
             {
                 ListControl lstControls = (ListControl)c;
                 if (lstControls.Items.Count > 0)
                 {
                     ListItem[] listItem = new ListItem[lstControls.Items.Count];
                     lstControls.Items.CopyTo(listItem, 0);
                     if (listItem.Contains(new ListItem(selectedText, selectedValue)))
                     {
                         lstControls.SelectedValue = selectedValue;
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemple #2
0
 public bool Contains(T item)
 => ListItem.Contains(item);