This has never happened before. It is not happening even in my visual studio. It is only happening on the live site. This never happened before on the live site either. I changed the master template but the change I made had nothing to do with the issue here. 3
[Code]....
Exception Details: System.InvalidCastException: Conversion from type 'DBNull' to type 'Integer' is not valid.Source Error:
Object cannot be cast from DBNull to other types. 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: Object cannot be cast from DBNull to other types. Source Error:
[Code]....
Line 292: Line 293: If DataBinder.Eval(e.Row.DataItem, "Casette") IsNot Nothing Then Line 294: stcassette += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Casette")) Line 295: End If Line 296:
There are two dropdowns for date (Fromdate and Todate) in my webpage and by default when the page loads for the first time the dropdowns loads with the last date (currentdate), if I select some previous date in Fromdate dropdown and reload the page then it displays runtime i.e.
Object cannot be cast from DBNull to other types.
Following code is written under GridView RowDataBound Event.
I fruther want to inform that some columns in the grid are showing 0 if there is no record but I replaced 0 to - then some 0s replaced and some not. What is the reason?
select SUM(PETTYAMOUNT) AS tot FROM FINPETTY WHERE PETTYAMOUNT IS NOT NULL AND CENTER = '1' if (drReadera.HasRows) { double totamta = Convert.ToDouble(drReadera["TOTALSUMA"]); Label2.Text = String.Format("{0:N2}", totamta); }
note: some of the pettyamount is null that's why i've got an error in page.
I have a webpage, i have a usercontrol in it , its name ispersonal1, i have tow Radiobutton in this usercontrol, the id of one of them ismale and the other one is female, it is obviously that each time we fill one of these radiobuttons and the other one will be null,in my database the type of these fields are bit , and they have allow null, i defined a property for my usercontrol like this:
Basically, what I did is that: I have a table in SQL database and some of data fields allow null. I built Objectdatasource through dataset. When I built update page using dataset. It generate the following error before showing the update page correctly. It seems I have issue to retrieve the null value from the database through using objectdatasource through dataset. Any suggestions?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
I get the error - Conversion from type 'DBNull' to type 'Integer' is not valid. - on the line.....
Dim newid As Integer = e.Command.Parameters("@latestRowId").Value.........in vb code behind.
I have the identical code for another page with the exception of the field names and it works fine. The only thing I did differently, as far as I know, is I copied the asp and code behind from the page that works into this page and manually changed the field and table names. I don't know what the problem is. Does anyone see any problems?
System.InvalidCastException was unhandled by user code
Message=Specified cast is not valid.
Source=App_Web_donate.aspx.cdcab7d2.wqdohvu3 StackTrace: at Donate.LoadUserDetails() in C:UsersSimonDesktopLocal SitesCats ProtectionNewDonate.aspx.vb:line 261 at Donate.btnDonate30_Click(Object sender, EventArgs e) in C:UsersSimonDesktopLocal SitesCats ProtectionNewDonate.aspx.vb:line 205 at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: I have made the important bits Bold I have the following code which is generating this error:
[Code]....
I am not entirely sure what is causing it. Its completley intermitent. I am storing all the details of a user filling in a form in a structure, and then assigning that structure to a session variable. This means if they page back, and then page forward again, I can pre-populate the form with the details they have already filled in for their conveinience by using the above code snippet. It appears that it works for a good minute, but if I leave the browser alone any longer than roughly 60 seconds, and then try and page forward to the form again, the exception will fire. While writing this post, the exception has occured in again in firefox, but interestingly, Google Chrome doesn't seem to have this problem. It looks like I can leave chrome alone for as long as I want and it will still work.
I am LINQ querrying against a datatable. However, I am unsuccessfull with catching null values. Here is my code that is giving me the following error.
[Code]....
I am checking to see if minperc is null. However to check that it still is trying to convert the value to double. Cant figure out a way around it. Here is the error: Cannot cast DBNull.Value to type 'System.Double'. Please use a nullable type.
I am trying to write a table output from SQL database to a gridview/ Data List through an Object Data Source. I am a new starter and your help will be useful.
public List<Staff> GetStaff() cmd.CommandType = SqlConnection con = new SqlConnection(connectionstring);SqlCommand cmd = new [code]...
I am attempting to use SqlBulkCopy to import data from an XML document. I receive the following error when executing WriteToServer: Invalid cast from 'System.String' to 'System.Guid'
I have following code in my class file which returns me the Date field in format like 4/4/2010 12:00:00 AM from SQL SERVER
public IEnumerable Mthgetcomplaintdate() { var v = objderma.USP_Patient_Dermatology_Complaints_RepDate(PatientID); ; return v as IEnumerable; }
But on my aspx page i want to display only the Date part not time.One way is i will iterated throgh my dropdownlist which am binding with the above method and i convert it using Toshortdatestring() method.But i want to cast the whole Ienumerable result using some method? I have read about cast<> ,but could not understand how to implement it exactly.
I have an optional DropDownList. If the user dosen't select any value the top most value is "0" unfortunatly the only way to send DBnull.Value to the database is check if the value is 0 and if it is then send dbnull. Is there a way you can do this within the dropdownlist without having to check for each and every dropdown?
I'm building an application that uses GridView controls to display data to a page.In my editemplate i have following control
<div class = "divBox"> <div>Beginn/Zeit 2</div> <div> <asp:TextBox ID="tbBeginn2" CssClass="fSelect" runat="server" Text='<%# Bind("beginnDatum2") %>'/> BeginnDatum2 has datetime-Format in SQL-Server.
For the update i use an objectDatasource with following updateparameter <asp:Parameter Name="beginnDatum2" Type="datetime" />
Now i'm trying to update this field but i have a problem when BeginnDatum2 must be null.
I get following (german) Errormessage:
SqlDateTime-Überlauf; muss zwischen 1/1/1753 12:00:00 AM und 12/31/9999 11:59:59 PM liegen. And this is my paramter Public Function UpdateSeminar(ByVal kursid As Integer, ByVal id As Integer, _ ByVal beginnDatum2 As DateTime, _ ByVal endeDatum2 As DateTime, _ cmd.Parameters.Add(New SqlParameter("@beginnDatum2", SqlDbType.DateTime)) If beginnDatum2 = Nothing Then cmd.Parameters("@beginnDatum2").Value = DBNull.Value Else cmd.Parameters("@beginnDatum2").Value = DateTime.Parse(beginnDatum2) End If
I know that the problem is my field having NULL values. However, I don't know how to have it process the code even if the field have nullshere's my code:
I am binding SQL data to a GridView. The GridView's DataKeyNames property is set to the SQL column called "utID"
I know that within the SQL results, some of the utID values are NULL. After databinding to the GridView, I need to enumerate through the GridViewRows an read the DataKey values. However, when I try this I get the following error:
No default member found for type 'DBNull'. I am using the code below.
What object types are stored within DataKeys (I thought it was just integers or strings)
How to handle a NULL datakey value to prevent this error occurring?
I don't want to use Try Catch because it's too much of a 'hack'
I have a question, that probably the solution is very simple, but I looked it up in the internet with no answer, the problem I'm having is, in a table I have a field, Qty (int, null) the thing that I want is in the report if the value is NULL shows 1 instead of a blank textbox, I know that the best solution is to change all the values in the database but I don't have permissions to do that, so what I need to do is a workaround in the report.