Forms Data Controls :: Dynamically Format String Value In Gridview?
Oct 23, 2010
I have a gridview that is built using a objectdatasource and set to autogenerate the columns based on that source, on some other pages i have a gridview that is built within the page with template fields and so on..
in that gridview i have a field that displays the time value like so
I am trying to format the cost as 10.00 but does not seem to have any effect at all. I get the values OK, but if the value of the string is 10.90, the output I get is 10.9
I'm trying to populate a detailsview according to the selected row in a gridview. How do you choose what the selectedindex is? For example my sql statement is:
An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
I am trying to sum the rows in a gridview. It works find except when I do an update. Then I get the following error:Input string was not in a correct format. The error occurs when it its the Total1 +=gr1.cells(5).text or the Total2 area. Here is my code to sum the rows:
I have a gridview to update soem records, it works on my development laptop but when i use it on the webserver i get the following error:
Exception Details: System.FormatException: Input string was not in a correct format.
Source Error: [Code]....
Stack Trace: [Code]....
I have another page with a gridview that does exactly the same but from another table, and that works both on the development laptop and the webserver.the code is:
i am creating a total column which multiplies the price by quantity in my gridview but am stuck on converting the input strings.
The price is stored as a decimal in my database and the quantity is a nvarchar.
i am receiving this error:
Input string was not in a correct format.
Description:
An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.FormatException: Input string was not in a correct format.
I have gridview control that has data binded by using EF. Whenever I try to sort my gridview I get this error: "Input string was not in a correct format." This error points to the following line of code: "int index = Convert.ToInt32(e.CommandArgument);"
AdministracijaVrstaAktivnosti.aspx
[Code]....
AdministracijaVrstaAktivnosti.cs
[Code]....
I'm not sure what do I have to fix if I want to sort the columns.
If I bind the data manually what is the code for codebehind to allow sorting for particular columns.
I'm getting "the input string was not in the specified format" on the last line of code below. The grid is based on a SqlDataSource that has a stored procedure pulling an integer for column 0.
Using C# and SQL server. I need to dynamically format a web page which is intend for reporting. I have 2 SQL tables. Projects ( Project ID and Project Name) and Subprojects ( SubprojectName, ProectID, EmployeeName, Decription). Subprojects are linked to the projects throughthe ProjectID field
Needed format; Employee Name
All the project for that EmployeeName All the SubProjects for that EmployeeName undre the given project + Description of the subproject Eg: Peter Project A SubProject AA <subProject AA Description > SubProject AB <subProject AB Description > SubProject AC <subProject AC Description > Project B SubProject BA <subProject BA Description > SubProject BB <subProject BB Description ANN Project C SubProject CA <subProject CA Description > SubProject CB <subProject CB Description >
if my data base field has any value then it shows no error. but if this fiels is null then it shows error input string was not in correct format while binding the gridview.
so can you please tell me the method that if this field has null value then what should I do so that i dont get this error. this fields might be null.
I'm stumped on this one... it seems really simple, but I can't get around it. I am pulling 2 values (discount percent, discount amount) from a formview label control. I want to use these numbers in a calculation, but I can't seem to get the format correct.
i have problem with manging format of string at run time
actually i have infomation in tabular form , a i am accessing that in coding in string fromat and send it by mail but when i send it shows html coding and not view in tabular .
I am getting "input string not in correct format" error and I have tried a few variations and still no dice. zSessvar1 is equal to 159 and when I substitute the actual nbr, it will work.
Dim cmd1 As OleDbCommand = New OleDbCommand("Select nbrofcomments from table1 where PID = " + zsessvar1, myConn)
I have a ListView control that pulls a phone number from a db table. I'd like to format the phone number in the presentation layer to look like (###) ###-####.
The code line currently looks like this. The page displays the phone# but unformatted, i.e. 9999999999.
[Code]....
Based on other posts I've looked at in this forum, I've also tried:
<li>Phone: <%# String.Format("{0:(###) ###-####}", Databinder.Eval (Container.DataItem("Phone"))) %> with no success. In fact, this particular line throws an exception in my application (Input string not in the correct format).
The datatype I'm using in SQL is varchar(15)
The MSDN documentation for the String.Format method hasn't been very helpful thus far.
Here is my problem When I try to edit this record, in the Edit mode, this Data field shows the number correctly with formatted e.g. 22,344 if I click on Save the record, it will give me the error "Input string was not in correct format". If I edit this number and remove the "," between numbers then it saves. What can I do to make this work? If I remove the "{0:#0}" then in the edit mode the number will show as 22344 without any comma separation. Note: On the same page I have other Data field of type "Money" and it works with the format applied ???? why does it works with the Money type and not Int???
http://www.codedigest.com/Articles/ASPNET/232_Picasa_Style_Photo_Album_Using_ListView_Control_in_ASPNet_35.aspx originally written in C#. I'm using VB.Net (Asp.net 4.0) and I'm getting the following errors for Albums.aspx, Photos.aspx, PhotoViewer.aspx pages. I have attached a screenshot of my two tables.Input string was not in a correct format.
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.FormatException: Input string was not in a correct format.
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.FormatException: Input string was not in a correct format.Source Error: [Code]....
Object reference not set to an instance of an object.
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.NullReferenceException: Object reference not set to an instance of an object.Source Error,[Code]....
I got a "Input string was not in the correct format" exception but can't see the problem. The exception had no information to show what was causing the error. It's thrown before the BLL or DAL are called so it must be in the mark up. The parameters are in the right order.[Code]....