Finding out if keyed in text is numeric:



//works only for whole numbers
int intDummy;
if (Int32.TryParse(string, out intDummy) {
 //text is numeric
} else {
 //text is not numeric
}


//this one works for decimals

 try { 
                Decimal cValue = Convert.ToDecimal(stringText);
               //bla bla bla...
            } catch (Exception exc) {
                errorText = "invalid non-numeric value. ";
            }


 
  System.IO.DirectoryInfo dirInfo = new System.IO.DirectoryInfo("X:\\File\\Path\\");
  System.IO.FileInfo[] files = dirInfo.GetFiles("*.ext");

  yourDropDownList.DataSource = files;
  yourDropDownList.DataBind();

OR we can do it the old fashioned way:

foreach (FileInfo file in files)  {
   yourDropDownList.Items.Add(new ListItem(file.Name));  
}



    About the author

    The author have 12+ years experience in IT Industry with varying job roles from system developer/analyst/consultant positions. Majority of her development, implementation and systems support background focus on Financial/Banking/Credit Solutions.

    Archives

    November 2010
    October 2010

    Categories

    All

    RSS Feed