C# : Number Conversion Problem?

Mar 27, 2010

Today I faced a strange problem in C#. I have an ASP.NET page where user can enter certain price, quantity etc. I get the price value, convert it to double, then multiply it with 100 and then typecast it to an integer. When the price is "33.30", after converting it to double it remains 33.3 (obviously...), but after multiplying it with 100, it becomes 3329.9999999999995, and when I cast it to integer by applying simple cast operator "(int) (price * 100) ", it becomes 3329.Right now I have no idea why this is happening.

View 6 Replies


Similar Messages:

Name Or Number Search In Textbox While Entering The First Letter Or Number Charactor Or Number?

Feb 2, 2010

I am using the asp.net and framework 2.0 with Ajax enable web.i have a text box and when user will enter "a" or number in this will search the name started from "a" character or number if he or she enter the number basically we can say live-search.

Employee search: Textbox.In this text box she/he will enter the first character of name or first number of employeeno and according to the a character name will search in list.

View 1 Replies

C# - Dynamically Append Number To PDF Or Make Submit Button Change Its URL Based On That Number?

May 4, 2010

I'm serving up PDFs from a SQL db and presenting them in the browser. I'm trying to figure out a way to embed a number in the PDF dynamically so that the recordID for that PDFs SQL record is available to me when the user submits the XML form data. The user hits the submit button on the form and the form submits its XML data to my submission page. If there is some way of changing the submission URL on the fly then I could do a query string to pass my self the recordID. I'm not generating the PDF in code, its being created by hand and then uploaded to my site.EditUser is given a link someServer.com/pdfLink.aspx?formID=5 they go there and that pages pulls a PDF from the DB and displays it. This pulls up acrobat in browser full size so my aspx page isn't in control of submitting the completed form, Acrobat is. The user fills out the form and hits the submit button in the form. This submit button was set up at form design time to point to another page someSite.com/pdfSubmit.aspx The submit button posts the XML data to that page and I can process it. I need the recordID in the query string for the someSite.com/pdfSubmit.aspx page. To do this I would need to modify the PDF to either add the recordID and query string to the submit button's submit URL, or embed it in the PDF else ware. The big question is how do I modify the PDF just before I display it via someServer.com/pdfLink.aspx?formID=5 to do either of these two options.

View 3 Replies

Data Controls :: View Limited Number Of Item From Large Number In Datalist?

Apr 15, 2013

 i want datalist to show only 6-8items ,as these datalist is connected to datasource which has more than 20 items..

like in facebook,we have lots of friends but in friend box only 6 friends is shown and when we click that we go to next page which display all list of friends...

View 1 Replies

Forms Data Controls :: When Casting From A Number The Value Must Be A Number Less Than Infinity

Mar 10, 2011

I get this message when i go to update formview.

View 2 Replies

Forms Data Controls :: When Casting From A Number, The Value Must Be A Number Less Than Infinity

Sep 30, 2010

The following code gives error: "When casting from a number, the value must be a number less than infinity."

<asp:TemplateField HeaderText="DATE" SortExpression="date1">
<ItemTemplate>
<asp:Calendar ID="Calendar1" runat="server"
SelectedDate='<%# Bind("date1") %>' VisibleDate='<%# Eval("date1") %>'>
</asp:Calendar>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="Date1" runat="server" Text='<%# Bind("date1") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>

The error occurs at the line <asp:Calendar ID="Calendar1"...>

It errors because there are records with null value for date1 when the records are returned from the database.

Is there a way to specify in the .aspx file telling it to ignore null or display null/blank?

View 2 Replies

C# - The Number Of Users Online And Number Of Active Session?

Mar 12, 2011

My environment is ASP.Net + IIS 7.0 + Windows Server 2008 + .Net 3.5. I am wondering whether the number of users online and number of active session are the same thing? The other question is, no matter whether they are the same, how to calculate them (i.e. for a given time, what is the number of users online, and related active number of sessions)?

View 1 Replies

DataSource Controls :: Number 1 Working As The Same As Number 2?

Apr 22, 2010

any one know why are the following two give me different result? they should both give me no results as the value I give is not available. however, number 1 give me many results, and number 2 works as expected. I'd like the number 1 working as the same as number 2.

1. DECLARE

@SearchMCat nvarchar,
@SearchTitle nvarchar,
@SearchDesc nvarchar
SET @SearchMCat = 'fjiewo;jafoia'
SET @SearchTitle = 'fryere'
SET @SearchDesc = 'fdsfdsafae33'
SELECT ArticleCategory.CategoryDisplayName, Article.AudioPlaybackTargetTabID, Article.VideoPlaybackTargetTabID, Article.StartTime, Article.DateAdded, Article.Body, Article.Synopsis, Article.Title, Article.ArticleHasAudio, Article.ArticleHasVideo, Article.createdBy,
Article.RatingTotal, Article.RatingCount, Article.ArticleID, ArticleCategory.CategoryName
FROM ArticleCategory RIGHT OUTER JOIN Article ON ArticleCategory.ArticleCategoryID = Article.MasterCategory
WHERE (ArticleCategory.CategoryName LIKE '%' + @SearchMCat + '%') or (Article.Title LIKE '%' + @SearchTitle + '%') or (Article.Body LIKE '%' + @SearchDesc + '%')

2.

SELECT ArticleCategory.CategoryDisplayName, Article.AudioPlaybackTargetTabID, Article.VideoPlaybackTargetTabID, Article.StartTime, Article.DateAdded, Article.Body, Article.Synopsis, Article.Title, Article.ArticleHasAudio, Article.ArticleHasVideo, Article.createdBy, Article.RatingTotal, Article.RatingCount, Article.ArticleID, ArticleCategory.CategoryName
FROM ArticleCategory RIGHT OUTER JOIN Article ON ArticleCategory.ArticleCategoryID = Article.MasterCategory
WHERE (ArticleCategory.CategoryName LIKE '%' + 'fdsafdsafdsa' + '%') or (Article.Title LIKE '%' + 'fffaery' + '%') or (Article.Body LIKE '%' + 'fdas3r43ffdsa' + '%')

View 4 Replies

PHP To .Net Conversion?

Feb 23, 2011

I am converting an old PHP porject over to ASP.Net (vb) and wondered if someone could point me in the right direction in order to convert this final snippet of code.

There are 3 functions that are called from within this and i ahve converted those already and to be honest is the session arrays that are giving me the headache.

I have thought about using Hashtables and DirecCasting but this was just confusing me further.[code]....

View 1 Replies

Forms Data Controls :: Display The Current Page Number And The Total Page Number In The Report Footer?

Aug 10, 2010

I have a web user control with DataList control in it. In my .aspx page, I have a report header, an empty panel as a place holder, a report footer.In my .aspx.vb file, I'll loop through a list of departments. Within each department, I'll load a label to display the department name and the user control for the data, and add both the label and user control to the panel. So there are two variables:
the number of departments and the number of records in a user control.

Now I need to display the current page number and the total page number in the report footer. Is it doable? How? I'm thinking of this approach: declare a page variable count, count the number of department name labels and the number of records in a user control. When the total count reaches a number, such as 20, I'll break the page. This way, I can get the the page current number and the total number of pages. But how to add a page break to an asp.net page?

View 8 Replies

Conversion Of Html To Pdf

Jan 8, 2010

I am converting an html into pdf, I have observed that the pdf is getting generated but not properly. i.e. the Datalist2 and the gridview2 present inside the Datalist2 is not getting populated.

<table id="tblReport" runat="server">
<asp:DataList ID="DataList1" runat="server">
<ItemTemplate>
<tr>
<td>
<asp:Label ID="lbl1" runat="server"> </asp:Label>
</td>
</tr>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lbl1" runat="server"> </asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>..............

View 3 Replies

Conversion - Possible To Convert Asp To Asp.net

Jun 17, 2010

I have been tasked with sifting through the worst classic asp spaghetti i've ever come across.The script runs a series of recordsets in sequence, getting 1 record at a time. As the record is built it takes the id and passes it to the next loop, which gets data, and passes on the id to the next loop. It then continues in this manner and builds an unordered list, kicking out the required html

View 1 Replies

C# List Conversion In .net?

Aug 22, 2010

I have a business object class BusinessObject which implements an interface IAlternateInterface. I already have a method that will return a generic list of BusinessObject which has the objects I want but I want to get them as a list of IAlternateInterface. I tried to do something like the following psudo code but I am getting a "Can not convert source type ... to target type ..." message in Visual Studio. What is the best way to convert the list?

public List<BusinessObject> GetObjects(){
//logic to get the list
}

public List<IAlternateInterface> GetInterfaceObjects(){
return GetObjects();
}

View 3 Replies

AJAX :: Error "Invalid Home Number. Number Should Be In The Format: 555-123-4567" With MaskedEditExtender

Oct 28, 2010

My requirement is, I have one text box and that text box accepts US Format 10 digit phone number like 555-555-5555. I want when user enter 5555555555 it automatically convert this in 555-555-5555 and if he enter some wrong number then show him error and if dont want to enter any thing then there should not be any error.

<th style="width: 150px">Home Telephone </th>
<td>
<asp:TextBox ID="txtHome" runat="server" MaxLength="12" ValidationGroup="vUserDetailsB" Width="252px" CssClass="txtBox" TabIndex="19"></asp:TextBox>
<cc1:MaskedEditExtender ID="meeHome" runat="server" TargetControlID="txtHome"
AutoComplete="false" MaskType="None" Mask="999-999-9999" ClearMaskOnLostFocus="true" InputDirection="LeftToRight" />
<%-- <cc1:MaskedEditValidator ID="mevHome" runat="server" ControlToValidate="txtHome"
EmptyValueMessage="Telephone Number is required." ValidationGroup="vUserDetailsB"
ControlExtender="meeHome" InvalidValueMessage="Valid Telephone Number is required."
IsValidEmpty="false" ValidationExpression="^d{3}-d{3}-d{4}&#36;" Font-Size="8pt" />--%>
<asp:RegularExpressionValidator ID="revHome" runat="server" ControlToValidate="txtHome" Display="Dynamic" ErrorMessage="Invalid Home number. Number should be in the format: 555-123-4567" Font-Size="8pt" SetFocusOnError="True" ValidationExpression="d{3}-d{3}-d{4}"
ValidationGroup="vUserDetailsB" Width="100%" meta:resourcekey="txtHomeResource1"></asp:RegularExpressionValidator>
</td>

Whats happenening, If i entered any thing like 5555555555 and it is coverting to this 555-555-5555 format which is correct and then when i moved to another textbox it is throwing error "Invalid Home number. Number should be in the format: 555-123-4567" and this format changes to 5555555555 and its not going ahead.

View 3 Replies

Vb.net Converting An Exponent Number To A Whole Number?

Dec 7, 2010

How can I convert a number with exponent value (such as 4.775900000000000e+004 ) to return a whole number, such as 47,759 using .net2.0 framework?

FYI, this is a weight category, not currency.

View 1 Replies

Looking For Date Format Conversion?

May 13, 2010

I am trying to convert a date pulled out from a data reader into the following format 'dd/mm/yyyy'.I have this line of code:
PHP Code:

System.Convert.ToDateTime(dbReaderAppl["date_addedd"].ToString())

But how can i convert the date to this format?

View 7 Replies

ADO.NET :: DateTime Conversion From Sql Into Datatable?

Jan 20, 2011

I'm having a bit of bother here with Null values in my sql table typically with DateTime fields[Code]..

View 5 Replies

Web Forms :: How To Date Conversion On The Fly

Jul 28, 2010

Im after some advice on date format conversions. I am working on a project that has raddatepicker controls that will take values chosen in the UI and uses them as constraints on a SQL query going back to the database.

My problem lies in the fact that the UI has a sensible date format (dd/mm/yyyy), whereas the database stored dates as "the number of seconds past 00:00:00 01/01/1970". In T-SQL, I can convert using:

[Code]....

I have no idea how to achieve this same conversion in C# so the user can choose a friendly format, but subsequently pass back the database date format.

View 6 Replies

How To Convert Timezone Conversion

May 15, 2010

How do I convert timezone from this format "03/03/2010 03:24:42 PM EST" to the current timezone in asp.net?

View 2 Replies

ConvertEmptyStringToNull="false" And Yet The Conversion Still Happens?

Jan 31, 2010

etailsView is bound to ObjectDataSource. Inside Detailsview's EditItemTemplate are two TextBoxes ( T1 and T2 ). T1 is mapped to update parameter of type String, while T2 is mapped to update parameter of type DateTime. ssuming both TextBoxes contain an empty string, then when I try to update the data source by clicking on DetailsView's Update button, ODS ( or is it perhaps DetailsView ) automatically converts T1's empty string to null, while T2's empty string doesn't get converted to null. I've tried to prevent ODS from converting T1's empty string to null by setting T1's update parameter's ConvertEmptyStringToNull property to false ( I 've also set <asp:TemplateField ConvertEmptyStringToNull="false" ...>, but to no effect.a)Any idea why T1's empty string gets converted, while T2's doesn't?b) Also, how can I prevent the conversion( BTW - I realize I could convert null back to empty string inside update method )?

View 1 Replies

VS 02/03 Conversion Ajax Enabled Website?

Oct 1, 2010

I've asp.net 2.0 ajax enabled web site in which I used Ajax update panels in pages. Now I want to convert it into asp.net 3.5 but it gives errors for Ajax tool kit and script manager and update panel used in pages. I don't want to remove ajax functionality from my site, so is there a way to convert them without removing ajax update panels from pages.On my PC I've installed both VS2005 and VS2008.

View 6 Replies

VS 2008 Conversion From 2005 Project

Apr 16, 2010

I have a Visual Studio solution created in 2005 and I want to start working with it in 2008. I opened it and it was run through the wizard. My first error is a message that says: The Web Applicatin Project is configured to use IIS. You must install the following IIS components: IIS 6 Metabase and IIS 6 Configuration Compatibility.So, I googled that and found this:IIS 7.0 is included with Windows Vista. However, when you first install Windows Vista, by default IIS 7.0 is not enabled. This topic describes how to enable IIS and configure it so that in Visual Studio you can create local IIS ASP.NET Web sites. This enables you to use a local copy of IIS to run and debug the Web site instead of using the ASP.NET Development Server.The bold is mine, because I want to know why I can't just use the ASP.NET Development Server? I always have in the past. Oh, and I'm not running Vista, I'm running Windows 7, but I don't think that matters.

View 18 Replies

Web Forms :: How To Prevent Automatic Conversion From .CSV To .XLS

May 7, 2010

I have a web page which generates a .CSV file based on some user input. When this file is downloaded by the user, the file is being automatically converted to .XLS. Any idea how I can prevent this?

For example, I am redirecting the user to the URL of the generated file, like below URL:

http://localhost/reports/Work/aa.csv

But the download window appears to download "aa.xls"!

View 6 Replies

How To Convert String To Integer Conversion

Apr 11, 2010

to convert string value "5%" to integer...I try to use Val(),Convert.ToInt32().... I still got error

View 10 Replies

Web Forms :: Complex Word Doc To Pdf Conversion

Jan 22, 2010

I need to convert the word doc to pdf, ofcourse i did it,But i converted only simple word file that has only strings. But I need to convert the word doc that has images tables with all formatings how Can i achive it.

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved