Tuesday, October 25, 2016

Friday, October 7, 2016

Get all selected items from checkbox



EX 1:


 List<ListItem> selected = chk_SEZ_Fields.Items.Cast<ListItem>()
    .Where(li => li.Selected)
    .ToList();


Ex 2:


List<ListItem> selected = new List<ListItem>();
foreach (ListItem item in CBLGold.Items)
    if (item.Selected) selected.Add(item);
If you just want the ListItem.Value:


Ex :3 

List<string> selectedValues = CBLGold.Items.Cast<ListItem>()
   .Where(li => li.Selected)
   .Select(li => li.Value)
   .ToList();


if you want yo add to a list on buttonclick

private void btn_Click(object sender, EventArgs e)
{
    for (int i = 0; i < chBoxListTables.Items.Count; i++)
    {
          if (chBoxListTables.GetItemChecked(i))
        {
            string str = (string)chBoxListTables.Items[i];
            MessageBox.Show(str);
        }
    }
}

read the list and check the items on checkbox list on values
where Selected is the list of string with items

 for (int i = 0; i < selected.Count; i++)
            {
                if (selected[i].ToString() == "Coega Industrial Development Zones")
                    CheckBoxList1.Items[0].Selected = true;
                if (selected[i].ToString() == "Dube Trade Port IDZ")
                    CheckBoxList1.Items[1].Selected = true;

            }



check if the list contains specific value


   if (selected.Any(t => t.Text == "Other"))
            { TextBox1.Text = "test"; }
            else

                TextBox1.Text = "123";

Tuesday, October 4, 2016

check version of SQL running on server

select serverproperty('Edition')

select serverproperty('EditionID')



-1253826760 = Desktop
-1592396055 = Express
-1534726760 = Standard
1333529388 = Workgroup
1804890536 = Enterprise
-323382091 = Personal
-2117995310 = Developer
610778273 = Enterprise Evaluation
1044790755 = Windows Embedded SQL
4161255391 = Express with Advanced Services

Monday, October 3, 2016

show/ hide a TabPage in a ASPxPageControl

MyTabControl.TabPages[0].PageVisible = false;



 ASPxPageControlTab.TabPages.FindByName("TabPageTest1").Visible = false;