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:
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?
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 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 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.
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:
3rd party ASP.Net web site and web service installed. The code appears not to log errors to server log or custom error log.
User receives the following critical untrapped error message:
"System.Web.Services.Protocols.SoapException: Unable to cast object of type 'System.Security.Principal.WindowsIdentity' to type 'Library.Security.Identity'. at ....."
Of course I understand the type cast issue but why would a IIS recycle resolve the issue?
I get this error when trying to export selected rows in gridview to pdf format
"Unable to cast object of type 'iTextSharp.text.html.simpleparser.CellWrapper' to type 'iTextSharp.text.Paragraph'."
This my code below:
using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter hw = new HtmlTextWriter(sw)) { gdfacture.Columns[0].Visible = false; foreach (GridViewRow row in gdfacture.Rows) {
I am trying to pass a collection of Dropdown controls as a parameter to a method which takes a collection of type Control as input. While executing I get the following error:
"Unable to cast object of type 'd__a31[System.Web.UI.WebControls.DropDownList]' to type 'System.Collections.Generic.IEnumerable1[System.Web.UI.Control]'."
This error is occuring randomly, and I can't seem to pinpoint what is causing it. For the most part, the code works fine. I'm confused why it works sometimes, but then suddently craps out on me, lol.It happens in the code when I call upon the asp.net membership provider. It only seems to happen when i use Membership.GetUser() to grab the logged in user's information.
I have installed the final version of Crystal Reports for Visual Studio 2010. I created a new ASP.Net project, saved it, closed it, and then came back to it later. I was prompted to convert the project because of an out of date version of Crystal Reports. But I just created the project...how can the version already be out of date? Also, once the conversion is complete the CrystalReportViewers error stating "Unable to cast object of type 'CrystalDecisions.Web.CrystalReportViewer' to type 'CrystalDecisions.Web.CrystalReportViewerBase'. I am using .NET Framework 3.5 (I cannot use 4.0 for other reasons). Is this the cause?
have a table that keeps track of customer data that is beyond the scope of the Membership Class, this table I am also using the Membership.CreateUser() generated user ID.When I use my INSERT statement however to create a new row in my table I keep getting the Specified cast is not valid error.This is my SQL Command (The ...refer to other fields)
Dim mySqlCommand As String = "INSERT INTO Customers (UserID, ...) VALUES (@UserID, ...)" I send it to my Write_Database(mySqlCommand, Membership.GetUser(txtUserName.Text).ProviderUserKey, ...) function which then I also tried sending he UserID as: CType(Membership.GetUser(txtUserName.Text).ProviderUserKey, SqlGuid)
Neither Works...both cause errors...My Write_Database Function is declared as follows:
Public Function Write_Database(ByVal MysqlQuery As String, ByVal UserID As System.Data.SqlTypes.SqlGuid, ...)
However Visual Studio shows that the error originates in the function calling code...
I'm a noob to ASP.Net and I'm working on a simple project. In this project I have 2 drop down lists.In one drop down list I would like to select a panel web control and with the other select the background color for that panel.I can change the background color by calling the method Color.FromName() but selecting the panel object by casting it to a panel object from a string in a drop down list is stomping me.This is my starting code:
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 building an ASP.NET application that needs dynamic tables. That's another issue that I've already posted about (and gotten a pretty good response!). Now, I'm running into another issue - I want to add new rows to my table, but given that I will have 10-12 tables on one page, each containing different objects in their rows (text boxes, check boxes, etc.) I need a way of simply generically adding a new row that has the same objects as the first row in the table. Here's my code:
Private Sub AddTableRow(ByRef originalTable As System.Web.UI.WebControls.Table) Dim originalRow As System.Web.UI.WebControls.TableRow = originalTable.Rows(1) Dim insertingRow As New System.Web.UI.WebControls.TableRow Dim insertingCells(originalRow.Cells.Count) As System.Web.UI.WebControls.TableCell Dim index As Integer = 0