10/07/2012,Will go to swimming at 10.30 *
30/11/2012,Will go to swimming at 15.30 *
When I load the form, the data should be shown in the corresponding textbox. For example Will go to swimming at 15.30 * must be shown under text box with label "30 November Friday" (because it corresponds to date 30/11/2012). My code so far is this:-
while ((line = sr.ReadLine()) != null)
{
string[] inData = line.Split(',');
key = inData[0];
value = inData[1];
hT.Add(key, value);
foreach (DictionaryEntry dataEntry in hT)
{
//Will throw a FormatException if 'dataEntry.Key' doesn't represent a valid date format
DateTime keyAsDate = Convert.ToDateTime(key);
//This overload of 'ToString' uses CurrentCulture
string comparisonKey = keyAsDate.ToString("dd MMMM dddd");
if (label1.Text.Equals(comparisonKey, StringComparison.OrdinalIgnoreCase))
{
textBox1.Text = dataEntry.Value.ToString();
}
if (label2.Text.Equals(comparisonKey, StringComparison.OrdinalIgnoreCase))
{
textBox2.Text = dataEntry.Value.ToString();
}
if (label3.Text.Equals(comparisonKey, StringComparison.OrdinalIgnoreCase))
{
textBox3.Text = dataEntry.Value.ToString();
}
Nothing is displayed after i load the form. The textBoxes are empty. I just can't seem to place the error. How can i fix this?
Thank you

New Topic/Question
Reply



MultiQuote





|