Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'.

Hi,

I have developed a custom server control for .NET Framework 2.0. The server control has a property named BinaryData of type byte[]. I marked this property to be data bindable. Now, I have varbinary(Max) type of field in my SQL Database and I have used SQLDataSource and bound this varbinary(Max) field with the property BinaryData (byte[]) of my control. It is working fine as long as the data value is not NULL. Now, In my control, I have handled the NULL value so that no Exception is thrown. Still, when I bind this property using the SQLDataSource, I get Error "Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'." I am not sure if I can do anything to stop this erro within my control. If it is not possible from the control, then what is the workaround that I can do in my ASPX page in order to stop this error ?

Thanks a lot in advance.

0
emran834
8/13/2007 9:35:57 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

11 Replies
4512 Views

Similar Articles

[PageSpeed] 41
Get it on Google Play
Get it on Apple App Store

You are reading in these values from a reader and casting them to their appropriate values. However, since you allow null values in your database table, if there is a null value in your resultant set, it will return DBNull.Value to your reader. This value cannot be casted into a primitive type. Thus you must check for it when you are reading it in and assign it accordingly. For instance,

this._strSomeValue = (sdrReader["SomeField"] == DBNull.Value)? "assign default value" : sdrReader["SomeField"].ToString();

basically check if it is DBNull.Value when you are reading it in, if it is, then manually set it to a default value, in your case you would use a empty byte array. 

0
triggered
8/13/2007 9:49:16 PM

.

2
emran834
8/14/2007 3:02:44 AM

.

0
emran834
8/14/2007 3:04:24 AM

Dear Ryan,

Thanks a lot for your reply. Actually I am the control developer and I am supplying my control to my client. Now, within my code, i have the property of byte[] type. And this property is databoundable. Now, where can I place your snippet in the code of my control ? I mean, my code has following definition of the byte[] type property,

1           private byte[] binData;
2   
3            [Bindable(true)]
4            [Category("Data Input fields")]
5            [Localizable(true)]
6            public byte[] BinData
7            {
8                get
9                {
10                   try
11                   {
12                   
13                   }
14                   catch
15                   {
                          binData = null;
16                   }
17  
18                   return binData;
19               }
20               set
21               {
22                   try
23                   {
24                       binData = value;
25                   }
26                   catch
27                   {
28                       binData = null;
29                   }
30  
37               }
38           }
39  

 

Now, How can I access the datareader of the SQLDataSource or any datasource that has bound this property and override this error message ?

Regards.

 

0
emran834
8/14/2007 3:05:40 AM

hmm. why do you try catch everything? Heavy on the processing. Let the error get thrown so the user knows why they were stupid. LOL.  Anyways, the responsibility lies within the class that is binding to your datasource. Its not like .net protects us from trying to bind a  string to an interger variable. So why should you do the same? You can give them a dope car, but cant teach them how to drive. Sorry, thats really all I can say on this.  Perhaps, maybe if you have a class that manages the assignment of the data source I can see something in a different light. Take care.

0
triggered
8/14/2007 3:22:05 AM

Dear Ryan,

Thanks a lot for your kind response.

 Actually, I was confused and I thought, may be I could do something within my sourcecode which could check the NULL value for the databound property. Because, when I have a label's Text property bound to a SQL varchar(x) type and if the SQL contains NULL for that varchar(x), we dont get this "Unable to cast....." Exception, rather, the Label shows Empty String. Same thing like CheckBox. If I bind "Checked" property of a checkbox to a SQL bit type field, and if SQL contains NULL value for that bit field, we dont get Exception, rather we see unchecked state of the CheckBox. So, I thought, the control developer made some smart way to handle databound NULL values for the Label and CheckBox. If so, as a developer, I also could do something for my Byte[] property.

I understood that it was my client's responsibility to find out the solution. But as a developer, I myself even could not find out the workaround for this problem in my page. For example, I want to use my own control for my varbinary(x) fields in SQL. And I used SQLDataSource to bind the Byte[] BinData property. It is very usual that I may have NULL values for some of the records in my SQL database and I want to use this control right a way to show the binary content. In this case, I would need to know either within Control's Source Code or Outside the control (Page's source code) I should use some snippet of code to handle this issue. And thats what I would like to know what is the soluition for this Error.

Regards.

0
emran834
8/14/2007 10:01:00 AM

how about ....

 

public byte[] BinData
{
get { return this._bBinData; }
set
{
if(value.Equals(DBNull.Value) || value == null)
{
// set to initialized byte array or byte[] representation of a empty string like
        // this._bBinData = System.Text.Encoding.UTF8.GetBytes(String.Empty);
}
else
{
this._bBinData = value;
}
}
}

basically, when the client is setting the value, if it is
any value of null, DBNUll or null, set it to a new instance
of a byte array, which will be set to its default value by
nature.
 
What do you think of this for a solution? It will fix your issue and still throw exceptions when needed. 
  
0
triggered
8/14/2007 2:29:55 PM

Hi Ryan,

Thanks a lot for the solution. I have tried your solution and modified my code as follows :

private byte[] binData;

        [Bindable(true)]
        [Category("Data Input fields")]
        [Localizable(true)]
        public byte[] BinData
        {
            get
            {
                return binData;
            }
            set
            {
                if (value.Equals(DBNull.Value) || value == null)
                {
                   binData =  System.Text.Encoding.UTF8.GetBytes(String.Empty);
                }
                else
                {
                    binData = value;
                }
            }
        }

Still I found error when I ran the web application. Here is the screenshot:

It looks like, the FrameWork tries to cast the read value (in this case DBNULL) to byte[] type before it assigns to the control's property so the control is not getting chance to override this process before the SQLDataSorce, am I right ? If so, is there any other idea available for this ?

Thanks again for your kind patience.

Regards

Nishat

0
emran834
8/14/2007 3:31:29 PM

Correct. I mentioned before that this is going to occur when the value is being read in, and I thought you responded with, you dont have control of this. You are using an actual datasource control or your own class? I would recommend creating your own class that generates a list of objects you need from an internal constructor where you can handle this with the SqlReader. Let me know which way you want to go or if you need further details. If you absolutely want to use a data source control, then handle the event during OnDataBinding.

 

The picture just loaded for me... Can you also just possibly add a public function in there like  BinData='<%# MyPublicFunction("imagedata") %>

where your public function will filter your data. This will work, but not recommended. Your class really should have all this handled behind the scenes and act as a interface to the user. So i would recommend the above method with internal constructor. 

0
triggered
8/14/2007 7:46:36 PM

Hi Ryan,

Thanks again. Yes, I tried using public function for the binding method to filter the data and it works. But it works only for ITEM template of the GridView. I want to use this control in the Edit Template and Insert template too and in those cases, I can not use a public function in place of BIND statement, right ? So, this method is not useful in general.

 I wont have any datasource control of my own class, rather, I always use SQLDataSource Control that comes with Visual Studio. And all my problem is with this data source control. As my users are most likely using SQLDataSource, and I will need to instruct them about the workaround for NULL values. So, in this case, would you please kindly give me the snippet for handling event of OnDataBinding, and which control's DataBinding Event should be handled ? Sqldatasource's ? or My Control's ?

 Regards

Nishat

0
emran834
8/14/2007 9:52:07 PM

Please take a look at this tutorial to its full extent. It explains nicely what I am talking about.

http://msdn2.microsoft.com/en-us/library/Aa479341.aspx

0
triggered
8/14/2007 10:40:49 PM
Reply:

Similar Artilces:

System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'
Hello , I am a data table with null able Columns.I am not able to catch the value for DBNull. I did set a value to be returned as empty in dataset. Here is the code where i am trying to catch.1 public List GetStores() 2 { 3 List tmpStore = new List(); 4 StoresService.shopDBDataSet.StoresDataTable stores = 5 storesService.GetStores(); 6 for (int i = 0; i < stores.Count ; i++) 7 { 8 Store store = new Store(); 9 store.StoreID = stores[i].StoreID...

System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.Byte[]'.
Hi All, I am trying to retrieve a Picture from an SQL 2005 database. Here is my code:Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim ListingID As String = (Request.QueryString("GUID")) 'Connect to the database and bring back the image contents & MIME type for the specified pictureUsing myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionStringListings").ConnectionString) Const SQL As String = "SELECT [Pic1Ext], [Picture1] FROM [Listings] WHERE [ListingID] = @ListingID"C...

Unable to cast object of type 'System.DBNull' to type 'System.String'.
Hi All, I am using Sql server 2005 and VS 2005 C#. Can anybody explain howz solve this prob? Unable to cast object of type 'System.DBNull' to type 'System.String'. 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.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.Source Error: Line 3496: get { Line 3497: try { Line 3498: ...

Unable to cast object of type 'System.DBNull' to type 'System.String'.
Hi i have the following which is meant to check if an image is available and if it isnt it should show a default image however, it gives me this error whenever the image is null in the database. This is the function which returns the error;protected string FormatImageUrl(object url) {if ((url != DBNull.Value) && (url != null) && (url.ToString().Trim().Length > 0)) { //if (File.Exists(url))return (url.ToString().Trim()); } else {return "~/images/default.gif"; } } Hey,Doesn't seem to pass the dbnull check.  Try to do:  if ((!DBNull.Valu...

Unable to cast object of type 'System.DBNull' to type 'System.String'.
Hi i get the following error, Unable to cast object of type 'System.DBNull' to type 'System.String'.  A generic image is meant to appear when no image is found in the database for a particular product, this is how the code is laid out;protected string FormatImageUrl(string url) {if (url != null && url.Length > 0) { //if (File.Exists(url))return (url); } else {return "~/Images/CompanyProducts/No_image.jpg"; } }   And the html is like this; <asp:Image ID="Image1" ImageUrl='<%# (string) FormatImageUrl( (string) Ev...

Unable to cast object of type 'System.DBNull' to type 'System.String'.
Hi there, If I add a new event and leave the description field empty the StarterKit seems to throw a big wobbly over the null values in my DB (SQL2000). Have I made a mistake in the installation or something? The problem lies in this line: SharedRoutines.truncate((string)Eval("description")) because description is Null. I want to sort this in this line and I don't want to reply on validators? This is a known issue reported in the Identified Bugs and Fixes for the ClubSite Starter Kit post. I don't think there is one definitive answer. Search on your error message and you'll fin...

Unable to cast object of type 'System.DBNull' to type 'System.String'
I have received the following error when I am logged in as administrator.  I wanted to test the load event feature.  Allows me to load and save new event.  I can view event on location view page but when I try to link to "list or calender" view I receive this error "Unable to cast object of type 'System.DBNull' to type 'System.String'.  Debug highlights the <asp:HyperlinkID as errored line. Any assistance would be greatly appreciated Brian   <DayEventTemplate> <div style="padding: 3px;"> <asp:Hyper...

Update error , "Unable to cast object of type 'System.DBNull' to type 'System.String'" , using DataSet as a datasource
Hi All, The following sample code is for testing dw.UpdateData using dataset as the data source. The data retrieval and display part under Form1_Load works fine. However, inputting some values in a new row and calling dw.UpdateData causes the following error: "Unable to cast object of type 'System.DBNull' to type 'System.String'" The error seems to occur when a datawindow column value has been changed from null value. Does anyone know how to fix the error ? Thank you for your advice. I use DW2.5 (build 8542), VS2005 pro, MS SQL Express. ...

Unable to cast object of type 'System.String' to type 'System.Byte[]' error
Hello, I have some binary data in a MySQL database, and im trying to convert it to a file. Before, when i was using the ms sql express 2005 database, everything was working fine. But then i migrated to MySQL because of budget issues. The following is the block of code that produces the error.private void showDbImage() {string ImageId = Request.QueryString["img"];   //build our query statementstring sqlText = "SELECT DownloadFile, DownloadType FROM DownloadTable WHERE DownloadName = '" + ImageId +"'";  OdbcConnection connection = new OdbcConnection( ConfigurationManager.ConnectionStrings["mySqlConnectionString"].ConnectionString ); OdbcCommand command = new OdbcCommand( sqlText, connection ); //open the database and get a datareader connection.Open();OdbcDataReader dr = command.ExecuteReader(); if (dr.Read()) //yup we found our file {Response.ContentType = dr["DownloadType"].ToString();Response.BinaryWrite((byte[])dr["DownloadFile"]); //downloadFile is the column that contains the binary data } connection.Close(); } However, when this code runs, i get the following error in my browser. Unable to cast object of type 'System.String' to type 'System.Byte[]'. The "DownloadFile" column contains the binary data of the file, and its a "LONGTEXT" type. Before, when i was using sql express 2005, the column was defined as an "image" typ...

Unable to cast object of type 'System.DBNull' to type 'System.String'. #2
 Hi:I am totally new to asp.net and downloaded the club website project. I have not done anything to the events page yet but as soon as i tried to add an event I got the following error. "Unable to cast object of type 'System.DBNull' to type 'System.String'." Can someone help me out here?ThanksBrian  This bug has been covered in the Identified Bugs and fixes section.  http://forums.asp.net/t/970081.aspx There are a few solutions and discussions on fixes, you will need to read through it to find the fix. Support@aspsksolutions.com Without kno...

Unable to cast object of type 'System.DBNull' to type 'System.String'. #2
I am getting this error when I try to run the code below. The error is happening on the last for each loop || foreach (string s in dr.ItemArray) || Please see below:        private void button1_Click(object sender, EventArgs e)        {            string myOutput = "";            DataTable dt = new DataTable();            using (TextReader tr = File.O...

Eventcalender: Unable to cast object of type 'System.DBNull' to type 'System.String'.
 I added an event in the eventcalender. When I try to view the events_calender.aspx I get this error message, what can be wrong??   Server Error in '/bfc_csk' Application. Unable to cast object of type 'System.DBNull' to type 'System.String'. 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.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.Source Err...

Unable to cast object of type 'System.Object[]' to type 'System.Data.DataView'.
I am tring to retieve a single node from my BLL code which retrieve one instane of Repot object:DataView dv = (DataView)objBoutPrep.Select();I am getting error:Unable to cast object of type 'System.Object[]' to type 'System.Data.DataView'. The BLL code returns onle one object and not a list of objects.Please help Client code: <asp:ObjectDataSource ID="objBoutPrep" runat="server" SelectMethod="GetRByID" UpdateMethod="UpdateT" TypeName="MB.K.BLL.G.Report"> <SelectParameters> <asp:Query...

How do I get around this error "Unable to cast object of type 'System.DBNull' to type 'System.String' "
I am using Visual Developer 2008 Express Edition for the first time, and I keep getting the following error below. The site allows anyone to enter with a valid username and password, but even when I logoff the site I get the same error....like the memory or database is not getting refreshed. I would think that when I initially compile the site that anything left in memory would be flushed out. Can someone please help me to figure this out. Thanks,Ramell P.S. The site is programmed using C#    Unable to cast object of type 'System.DBNull' to type 'System.String'. 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.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.Source Error: Line 57: } Line 58: Line 59: <asp:Label ID="Label2" runat="server" Text='<%# SharedRoutines.truncate((string)Eval("description")) %>' /> Line 60: <a href='<%# "News_View.aspx?Articleid=" + Convert.ToString(Eval("ID")) %>'>read more Line 61: &raquo;</a>Source File: e:\Web Site Portfolio\Greater_Mt_Olive\WebPartControls\RecentNews.ascx    Line: 59 Stack Trace: [InvalidCas...

Unable to cast object of type 'System.DateTime' to type 'System.String'.
 Hi,      I got this field (dateSubmitted) having a data type of DateTime but I receive this error "Unable to cast object of type 'System.DateTime' to type 'System.String'."       All value for dateSubmitted field are 12/27/2007 12:00:00 AM. cheers,imperialx  imperialx:I got this field (dateSubmitted) having a data type of DateTime but I receive this error "Unable to cast object of type 'System.DateTime' to type 'System.String'." Can you explain it further as to, where you're getting this error ?Thanks,Dhimant Trivedi"When the going gets tough, tough gets going.""Mark as Answer" the post(s) which helped you solve the problem  Hi dhimant,                    I have a Gridview and binded to a LinqDatasource, which shows all data field, one field is named dateSubmitted having a data type NCharVar but an error occurs if I set it to DateTime type. cheers,imperialx       imperialx:one field is named dateSubmitted having a data type NCharVar but an error occurs if I set it to DateTime type. AFAIK, the convert between nvarchar and datetime data type is implicit, which means you don't have to explicitly use cast or convert functions to convert a datetime value to nvarchar or vice versa...

Unable to cast object of type 'System.Int64' to type 'System.String'
Hi friends I am getting the following error..."Unable to cast object of type 'System.Int64' to type 'System.String'." for the following line of code  if ((QSDealID) == (dr.GetString(1).ToString()))...............need ur help...Gurjeet,England First of all, the ToString of the GetString method is not needed because the GetString will return a string. The prolem with your code is that QSDealID is of type System.Int64, right? So a Int64 can't be compared with a string. The DataReader have a method that can return a Int64, so instead of using GetString(1), use GetInt64. if (QSDealID == dr.GetInt64(1))/Fredrik Normén - fredrikn @ twitterMicrosoft MVP, MCSD, MCAD, MCTASPInsidersMy Blog is ur QSDealID is interger??? i think if it is then u r required to convert it into string or convert dr.Getstring(0).tostring into Int64Thanks, Mahadeo-----------------------------------------------Best is Not the END point, but a starting point for Innovation------------------------------------------------Remember to mark posts as the "Answer" to help future users....

Unable to cast object of type 'System.String[]' to type 'System.IConvertible'.
hi expert   i try get the string from request.querystring("CID") from the error messege i know that is string[] (array) how to convert it to int32 and request.querystring("CID") is int value   Line 19: protected void ObjectDataSourceCarPicture_Inserting(object sender, ObjectDataSourceMethodEventArgs e) Line 20: { Line 21: e.InputParameters.Add("CID", Convert.ToInt32(Request.QueryString.GetValues("CID")) ); Line 22: // e.InputParameters.Add("CID", Convert.ToInt32( Convert.ToString( a Request.QueryString.GetValues("CID"))))); Line 23: } i already try search from google but still not get the solution Why dont you carry it out this way: string result = Request.QueryString["CID"]; //Parses the given string, throwing some kind of error when its //not a number int cid = Int32.Parse(result);And then use the cid whereever you want!Hope that helps.So simple... yet so effective.My "Life"ly Blog thanks for reply it works other that i did a mistake Request.QueryString.GetValues("CID")   to Request.QueryString.Get("CID") Watch out for the other thing that I mentioned in my code.. you can use Request.QueryString["CID"] to index into the QueryString collection. Saves some hassle.Smiles.So simple... yet so effective.My "Life"ly Blog...

Unable to cast object of type 'System.UInt32' to type 'System.String'?
Hi all,I'm trying to retrieve a column in my table (MySQL), this is the primary key of that table, and here is my code: public string GetAsocPKByUserName(string UserName) { MySqlConnection conn = new MySqlConnection(); MySqlCommand myCommand = new MySqlCommand(); string ASOC_PK = string.Empty; try { conn = new MySqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); conn.Open(); myCommand = new MySqlCommand("SELECT Distinct ASOC_PK FROM associates WHERE UserName = '" + UserName + "'"); ASOC_PK = (string)MySqlHelper.ExecuteScalar(conn, myCommand.CommandText); } catch (Exception ex) { throw ex; } finally { conn.Close(); myCommand.Dispose(); } return ASOC_PK; } On my code-behind page, here is what I did:BlogsDS getID = new BlogsDS();Session["ASOC_PK"] = getID.GetAsocPKByUserName(Session["IUser"].ToString()) However, I receive this error each time I run it:Server Error in '/ERC' Application. Unable to cast object of type 'System.UInt32' to type 'System.String'. Description: An unhandled exception occurred during the execution of the current web request. Please review the st...

Unable to cast object of type 'System.String' to type 'System.Array'
I really need to get this working! I have dimensioned fnames in line 2 to 200 slots. This code gets all the file names in a subdirectory and places them into an array. First files(), a dynamic array, gets the full path. Then line 9 splits it up into it's parts. I grab the last part (the filename) and store it into fnames. The message is  Unable to cast object of type 'System.String' to type 'System.Array'.  How do I get this to work?  Filenames is an array. Line 9 works. It takes a string (str) and converts it into the Array filenames. Why doesn't the n...

Null values and Profile data "Unable to cast object of type 'System.DBNull' to type 'System.String'"
I've made my own ProfileProvider but when I am trying to read null values by txt.Text = Profile.FirstName I get the error "Unable to cast object of type 'System.DBNull' to type 'System.String'."This is how the code (which I don't write by myself looks like): How to fix the problem??public virtual string FirstName { get { return ((string)(this.GetPropertyValue("FirstName"))); } set { this.SetPropertyValue("FirstName", value); } }  You can check for a null value as sh...

System.InvalidCastException: Unable to cast object of type 'System.Web.HttpInputStream' to type 'System.IO.FileStream'
I am trying to create a webpage that takes a file that someone want to upload and chop the file into smaller pieces, and then put back together again.  I have been trying to convert some code I found on Codeproject (FileSplitMerge).  They did it with VB which is what I want to use but it is a project not a web site so...  The problem that I am running into is I keep getting an error when I try to set: FileStream = HttpPostedFile.InputStream (I am using variables in my code) but I keep getting an error of: System.InvalidCastException: Unable to cast object of type 'Sys...

Unable to cast object of type 'System.String' to type 'System.Data.DataRowView'
Hi, I am having this problem: Unable to cast object of type 'System.String' to type 'System.Data.DataRowView'I have two repeaters: One is for a list of terms and the other show the definition. What I am trying to do is, highlight the selected term.Here is the relevant code which has this error:private Color SetButtonBackColor(object dataItem){ Response.Write("<br />In SetButtonBackColor Function"); Response.Write("<br>dataItem in SetColor is: " +(string)((DataRowView)dataItem)["TermIndex"]); string _initial =  (string) ((DataRowView)dataItem)["TermIndex"];  Response.Write("<br>Initial is: "  + _initial + "<br />ViewState is " + ViewState["TermIndex"]);  if (_initial == (string) ViewState["TermIndex"])  return Color.Red; return Color.Blue;} private void BindTerm(object term){    //create a connection to the db    OleDbConnection oCxn = dbConnectDataDictionary();  ViewState["TermIndex"] = term; SetButtonBackColor(term); Response.Write("<br>term in BindTerm is: " + term); Response.Write("<br>ViewState in BindTerm is: " + ViewState["TermIndex"]);// FillGlossary(ref oCxn, TermsQuery, ref GlossaryRepeater, term);  //Data set Two  DataSet _data3 = new DataSet();  string _Query = "SELECT[attribute name] AS TermIndex, [attribute type], [source for raw data], definition FROM [Attributes] WHERE [Attribute Name] like ...

InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.
I get the above error when using the DynamicDataController for a simple schema that looks like the one listed below. It happens when there is actually data in the 2 tables and I try to list the contents of b. I have a sample application that demonstrates this in full if anyone needs it. The work-around is to add a varchar field to table a, and then the exception goes away. I'd rather not do this, so if you know of any code-based workarounds, I'm all ears. The full stack trace is also listed below the schema. If I need to report this to a better place, I'd be happy to do that. CREATE TABLE a (  [id] [int] IDENTITY(1,1) NOT NULL primary key,  [date] [datetime] NULL)CREATE TABLE b (  [id] [int] IDENTITY(1,1) NOT NULL primary key,  [a_id] [int] NULL,  [amount] [decimal](17, 4) NULL)ALTER TABLE [dbo].[b] WITH CHECK ADD CONSTRAINT [FK_b_a] FOREIGN KEY([a_id])REFERENCES [dbo].[a] ([id])GOALTER TABLE [dbo].[b] CHECK CONSTRAINT [FK_b_a]GO   [InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.] System.Web.DynamicData.DynamicMetaTable.GetDisplayString(Object value) +138 ASP.app_shared_dynamicdatafields_foreignkey_ascx.GetDisplayString() in c:\dev\mvc\DynamicDataFKBug\DynamicDataFKBug\App_Shared\DynamicDataFields\ForeignKey.ascx:6 ASP.app_shared_dynamicdatafields_foreignkey_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\dev\mvc\DynamicDataFKB...

Web resources about - Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'. - asp.net.sql-datasource

Resources last updated: 3/8/2016 2:35:56 AM