Error Specified Cast Is Not Valid In Asp.net
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Specified cast is not valid in ASP.NET? [duplicate] up vote -1 down vote favorite This question already has an answer here: “Specified cast is not valid” error in C# windows forms program 9 answers I got the following code: var model = new List
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign http://stackoverflow.com/questions/37441988/specified-cast-is-not-valid-in-asp-net up Specified cast is not valid using asp.net C# [duplicate] up vote 2 down vote favorite This question already has an answer here: “Specified cast is not valid” error in C# windows forms program 9 answers I have many check box lists for searching, but when select multiple checks for search then getting an error, below is my full code: private DataTable http://stackoverflow.com/questions/34304985/specified-cast-is-not-valid-using-asp-net-c-sharp list(String dbObject, String filterName, String filterValue,string PositonId,string Status) { NameValuePairList objNameValuePairList = new NameValuePairList(); objNameValuePairList.Add(new NameValuePair("@FilterValue", filterValue, PositonId, Status)); objNameValuePairList.Add(new NameValuePair("@Action", "FilterBy" + filterName, PositonId, Status)); DataTable dt = dl.Search_RegisterationInfo(dbObject, objNameValuePairList, PositonId, Status); return dt; } public DataTable list(String dbOject, FilterList myFilterList,string PositonId,string Status) { // gets a collection(dataset) of all unique filters(datatables) and also group all subfilters(rows) under each filter DataTable dt; DataSet ds = new DataSet(); // a filter may be a Nationality or a Qualification foreach (Filter item in myFilterList) // a subfilter may be Indian or Expatriate under the filter Nationality { // another subfilter may be Bachelor degree or Master Degree under the filter Qualification dt = list(dbOject, item.getFilterName, item.getFilterValue, PositonId,Status); dt.TableName = item.getFilterName; // datatables are named based on the filters if (ds.Tables.Count == 0) // so we get a collection of unique filters (datatables) in the dataset ds.Tables.Add(dt); // add new filter without checking, since for the first time, no conflicts are possible else { bool tableMatchFound = false; foreach (DataTable newdt in ds.Tables) if (newdt.TableName == dt.TableName) { // see if filter is already present in the da
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn http://stackoverflow.com/questions/5577484/specified-cast-is-not-valid-how-to-resolve-this more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community http://forums.asp.net/t/1885042.aspx?Specified+cast+is+not+valid+ Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Specified cast is not valid.. how to resolve this up error specified vote 24 down vote favorite 3 I have the below function public object Convert(object value) { string retVal = string.Empty; int oneMillion = 1000000; retVal = ((double)value / oneMillion).ToString("###,###,###.###"); return retVal; } I am invoking like var result = Convert(107284403940); Error: "Specified cast is not valid." how to fix... Note:~ the object value can be double, decimal, float, integer(32 and 64)..anything Is it possible to do the typecasting error specified cast at runtime? c# share|improve this question asked Apr 7 '11 at 7:32 learner 136139 add a comment| 2 Answers 2 active oldest votes up vote 49 down vote accepted Use Convert.ToDouble(value) rather than (double)value. It takes an object and supports all of the types you asked for! :) Also, your method is always returning a string in the code above; I'd recommend having the method indicate so, and give it a more obvious name (public string FormatLargeNumber(object value)) share|improve this answer edited Apr 7 '11 at 7:44 answered Apr 7 '11 at 7:33 Kieren Johnstone 25.7k855105 This will overflow for decimal as OP is saying value can be decimal. –Sanjeevakumar Hiremath Apr 7 '11 at 7:38 2 I don't think so: double.MaxValue is 1.7976931E+308, decimal.MaxValue is 7.9228E+24. Do you have a source? –Kieren Johnstone Apr 7 '11 at 7:41 2 Conversions from Decimal to Single or Double are narrowing conversions that might lose precision but not information about the magnitude of the converted value. because Decimal is 128 bit number where as double is 64 bits long –Sanjeevakumar Hiremath Apr 7 '11 at 7:44 1 Yes, it might lose precision, but it will not overflow. Your
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/General ASP.NET/Web Forms/Specified cast is not valid. Specified cast is not valid. [Answered]RSS 37 replies Last post Feb 27, 2013 02:57 PM by peshangm ‹ Previous Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered Threads Unresolved Threads Support Options Advanced Search Related Links GuidanceSamplesVideos Reply peshangm Member 46 Points 205 Posts Specified cast is not valid. Feb 24, 2013 06:22 AM|peshangm|LINK dear all when user want to register account the display this error : Specified cast is not valid. please what it the solution