Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want slove this problum ???????


ERROR Message

String was not recognized as a valid TimeSpan.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: String was not recognized as a valid TimeSpan.

Source Error:


Line 178: dropdowncourier.SelectedItem.Text= phoneGridView.SelectedRow.Cells[2].Text;
Line 179: dropdowngetphone.SelectedItem.Text = phoneGridView.SelectedRow.Cells[3].Text;
Line 180: TimeSpan PKTime = TimeSpan.Parse(phoneGridView.SelectedRow.Cells[4].Text);
Line 181: int hours = PKTime.Hours;
Line 182: int Minutes = PKTime.Minutes;



MY CODE

C#
 dropdowncourier.SelectedItem.Text= phoneGridView.SelectedRow.Cells[2].Text;
           dropdowngetphone.SelectedItem.Text = phoneGridView.SelectedRow.Cells[3].Text;
           TimeSpan PKTime = TimeSpan.Parse(phoneGridView.SelectedRow.Cells[4].Text);
                    int hours = PKTime.Hours;
                    int Minutes = PKTime.Minutes;
                    TimeSelector1.SetTime(hours, Minutes, TimeSelector1.AmPm);
   
          
txtremarks .Text = phoneGridView.SelectedRow.Cells[6].Text;
Posted
Updated 12-Nov-12 22:43pm
v2
Comments
Hasiya 13-Nov-12 4:51am    
I Need a quick help??????

It is simply saying that the contents of phoneGridView.SelectedRow.Cells[4].Text are not recognisable as a valie TimeSpan in string form. We can't fix that: it's your data that is the problem!

Have a look at the cell content, and at the Parse method description / example : http://msdn.microsoft.com/en-us/library/se73z7b9.aspx[^] - I don't know what your data looks like, so we can't correct your problem.
 
Share this answer
 
Please Try this,

C#
var dt = new DateTime(2010, 06, 26); // time is zero by default
               string currTime = "19:04:06";//dateTimePicker1.Value.TimeOfDay.ToString();//19:04:06
               var tm = TimeSpan.Parse(currTime);
               var fullDt = dt + tm;
 
Share this answer
 
Comments
CHill60 11-Jul-14 9:38am    
You're a bit late ...over 19 months late

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900