{"id":3492,"date":"2014-03-25T21:57:24","date_gmt":"2014-03-25T21:57:24","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/25\/linq-specified-cast-is-not-valid-with-dataview-use-collection-of-common-programming-errors\/"},"modified":"2014-03-25T21:57:24","modified_gmt":"2014-03-25T21:57:24","slug":"linq-specified-cast-is-not-valid-with-dataview-use-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/25\/linq-specified-cast-is-not-valid-with-dataview-use-collection-of-common-programming-errors\/","title":{"rendered":"LINQ &#8211; Specified cast is not valid with dataview use-Collection of common programming errors"},"content":{"rendered":"<p>I am trying to get the presence of rows based on the passed col. The column is coming from the database as MultiSelect.<\/p>\n<pre><code>bool bCFPresent = IsMultiSelectCFPresent(dvDataTag, \"MultiSelect\");\n\n\npublic static bool IsPresent(DataView dvDataTag, string colName)\n{\n  return ((from DataRowView drv in dvDataTag\n                     where drv.Row.Field(colName) == 1\n                     select drv).Count() &gt; 0 ? true : false);  \n}\n<\/code><\/pre>\n<p>But I am getting this error:-<\/p>\n<blockquote>\n<p>System.InvalidCastException was unhandled by user code<br \/>\nMessage=&#8221;Specified cast is not valid.&#8221; Source=&#8221;System.Data.DataSetExtensions&#8221; StackTrace: at System.Data.DataRowExtensions.UnboxT`1.ValueField(Object value) at System.Data.DataRowExtensions.Field[T](DataRow row, String columnName)<\/p>\n<\/blockquote>\n<p>Please help .<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am trying to get the presence of rows based on the passed col. The column is coming from the database as MultiSelect. bool bCFPresent = IsMultiSelectCFPresent(dvDataTag, &#8220;MultiSelect&#8221;); public static bool IsPresent(DataView dvDataTag, string colName) { return ((from DataRowView drv in dvDataTag where drv.Row.Field(colName) == 1 select drv).Count() &gt; 0 ? true : false); } [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3492","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3492","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3492"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3492\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}