473,549 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview + ObjectDatasourc e + UpdateMethod = Input string was not in a correct format

This is a problem that has been haunting me for days and I've come to a
complete dead-end. I'm using a objectdatasourc e to select and update a
gridview control. Populating with select works fine but updating gives
the "input string... " error. Any suggestions or links to a working
sample. Let me know if anyone needs any code posted...
Thanks in advance!

Apr 17 '06 #1
7 5167
what kind of input string error?

"M C" <mi************ **@gmail.com> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
This is a problem that has been haunting me for days and I've come to a
complete dead-end. I'm using a objectdatasourc e to select and update a
gridview control. Populating with select works fine but updating gives
the "input string... " error. Any suggestions or links to a working
sample. Let me know if anyone needs any code posted...
Thanks in advance!

Apr 18 '06 #2
Are you updating real or datetime values?

There's a bug in the ObjectDataSourc e that prevents it from working
properly if the current culture is "compatible " with the
InvariantCultur e. For more info take a look here:


The only thing you can do to bypass this error if you're using the
ObjectDataSourc e is to set your current culture to the InvariantCultur e
but probably this is not what you want to do as you'll loose your
datetime and real formats.

You can use my ExtendedObjectD ataSource that is a component with more
functionality than the ObjectDataSourc e:


You have to pay for the complete version but there's a free version
(look at the purchase page) that works like the ObjectDataSourc e and
doesn't have the "Input string was not in a correct format" error (but
doesn't have caching).

Hope it helps,

Apr 18 '06 #3
I'm only updating int and string values...
Here's a snippet of my code:

[ASPX page]:
<asp:GridView ID="gridViewNew s" runat="server"
AutoGenerateCol umns="False" DataSourceID="O bjectDataSource 1"
DataKeyNames="c id,rid">
<asp:CommandFie ld ShowEditButton= "True" >
</asp:CommandFiel d>
<asp:BoundFie ld DataField="cid" HeaderText="CID " ReadOnly="True"
SortExpression= "cid" />
<asp:BoundFie ld DataField="rid" HeaderText="RID " ReadOnly="True"
SortExpression= "rid" />
<asp:BoundFie ld DataField="cont rolvocabulary"
HeaderText="The saurus" ReadOnly="False "
SortExpression= "controlvocabul ary" HtmlEncode="fal se" />
<asp:BoundFie ld DataField="titl e" HeaderText="Rx Title"
ReadOnly="True" SortExpression= "title" />
<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
OldValuesParame terFormatString ="original_{ }"
SelectMethod="g etInvalidItemBy News" UpdateMethod="e ditNews"
<UpdateParamete rs>
<asp:Paramete r Name="original_ cid" Type="Int32" />
<asp:Paramete r Name="original_ rid" Type="Int32" />
<asp:Paramete r Name="controlvo cabulary" Type="String" />
</UpdateParameter s>
</asp:ObjectDataS ource>

[CLASS page with UPDATE method]:
public static void editNews(int original_cid, int original_rid, string
controlvocabula ry, string title) {
using (SqlConnection connection = new
SqlConnection(C onfigurationMan ager.Connection Strings["OFHC-RX_RxConnection String"].ConnectionStri ng))
using (SqlCommand command = new SqlCommand("lex _EditNews",
connection)) {
command.Command Type = CommandType.Sto redProcedure;
command.Paramet ers.Add("@conte ntid", SqlDbType.Int). Value =
command.Paramet ers.Add("@revis ionid", SqlDbType.Int). Value
= original_rid;
command.Paramet ers.Add("@contr oledvocabvalue" ,
SqlDbType.NVarC har, 1000).Value = controlvocabula ry;
int result = 0;
connection.Open ();
result = command.Execute NonQuery();
connection.Clos e();

Apr 18 '06 #4
Here's output error. I really have no clue to what or where this error

[FormatException : Input string was not in a correct format.]
System.Text.Str ingBuilder.Form atError() +54
System.Text.Str ingBuilder.Appe ndFormat(IForma tProvider provider,
String format, Object[] args) +2834404
System.String.F ormat(IFormatPr ovider provider, String format,
Object[] args) +93

System.Web.UI.W ebControls.Obje ctDataSourceVie w.MergeDictiona ries(ParameterC ollection
reference, IDictionary source, IDictionary destination, String
parameterNameFo rmatString) +229

System.Web.UI.W ebControls.Obje ctDataSourceVie w.ExecuteUpdate (IDictionary
keys, IDictionary values, IDictionary oldValues) +2113
System.Web.UI.D ataSourceView.U pdate(IDictiona ry keys, IDictionary
values, IDictionary oldValues, DataSourceViewO perationCallbac k
callback) +78
System.Web.UI.W ebControls.Grid View.HandleUpda te(GridViewRow row,
Int32 rowIndex, Boolean causesValidatio n) +1218
System.Web.UI.W ebControls.Grid View.HandleEven t(EventArgs e, Boolean
causesValidatio n, String validationGroup ) +853
System.Web.UI.W ebControls.Grid View.OnBubbleEv ent(Object source,
EventArgs e) +87
System.Web.UI.C ontrol.RaiseBub bleEvent(Object source, EventArgs
args) +35
System.Web.UI.W ebControls.Grid ViewRow.OnBubbl eEvent(Object source,
EventArgs e) +117
System.Web.UI.C ontrol.RaiseBub bleEvent(Object source, EventArgs
args) +35
System.Web.UI.W ebControls.Link Button.OnComman d(CommandEventA rgs e)
System.Web.UI.W ebControls.Link Button.RaisePos tBackEvent(Stri ng
eventArgument) +153

System.Web.UI.W ebControls.Link Button.System.W eb.UI.IPostBack EventHandler.Ra isePostBackEven t(String
eventArgument) +7
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +11
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData)
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)

Apr 18 '06 #5
I think you should change OldValuesParame terFormatString ="original_{ }"
to OldValuesParame terFormatString ="original_{0}" .

Hope it helps,
Manuel Abadia.

Apr 18 '06 #6
and I tried the culture thing too - it didn't help. Is that something
thats applicable to my problem. As I said earlier, I'm not dealing
with real or datetime values.

Apr 18 '06 #7
THANK YOU!!!! I finally got some meaningful errors and in a split
second I got it fixed!

Apr 18 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row *that is going to be deleted* into another table, before the original data is deleted. I am trying to use the RowDeleting method to call an Update...
by: M C | last post by:
Hi, This is a problem that has been haunting me for days and I've come to a complete dead-end. I'm using a objectdatasource to select and update a gridview control. Populating with select works fine but updating gives the "input string... " error. Any suggestions or links to a working sample. Let me know if anyone needs any code posted......
by: avital | last post by:
Hi, Hope someone can please help. I have a Gridview with a checkboxlist. On edititemTemplate I want the checkboxlist items to be selected as returned from the database. In the database I have a table called PrescriptionDetails with a field called Weekdays that can store data in the following format: Monday,Tuesday,Thursday,
by: =?Utf-8?B?RGVubmlzIE1jQ2FydGh5?= | last post by:
I am displaying data from a web service in a DataGrid, using an ObjectDataSource. Retrieving and displaying data is working fine, but there is a problem using Edit mode in the GridView. If my GridView contains columns that correspond exactly to the input parameters for the UpdateMethod of the ObjectDataSource, then everything works. ...
by: =?Utf-8?B?QWRhciBXZXNsZXk=?= | last post by:
Hi All, I have a GridView inside the EditItemTemplate of a FormView. Both FormView and GridView are data bound using an ObjectDataSource. When the FormView's ObjectDataSource object has a SelectParameters with a SessionParameter in the parameters collection and the object stored in the Session is a reference type, the DataGrid fails to...
by: tim.cavins | last post by:
I have a GridView populated by an ObjectDataSource. I am having issues passing the parameters to the objectdatasource. I have verified that the method is being called but none of the parameters are being populated. Integers are being passed as 0 and strings are empty regardless of what I changed them to in Edit mode on the GridView. My...
by: shapper | last post by:
Hello, I am working with a ListView but I suppose that with a GridView might be the same. Instead of having an Insert Button on each GridView row I would like to have only one Insert button, for example, in the GridView footer. When this button is clicked it should put the GridView in Insert Mode and the EditTemplate should be showed,...
by: steve | last post by:
I have been fighting with trying to update a GridView for a while. I don't want to use the "built-in" way to do it because I am using business layer methods for updating and deleteing and I don't want to have my parameter names in those methods have to be "original_Parametername" or even if I change the OldValuesParameterFormatString to get...
by: Jeff | last post by:
hi asp.net 2.0 I'm having problem updating a GridView. The problems is that the website complains it don't find the update method. The problem is caused by the updateparameters. The UpdateMethod take 3 parameters: Id (DataKeyNames), Kode and Desc. Here is the markup of both GridView and ObjectDataSource:
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.