473,669 Members | 2,385 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

M C
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 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!
MC

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

"M C" <mi************ **@gmail.com> wrote in message
news:11******** **************@ j33g2000cwa.goo glegroups.com.. .
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 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!
MC

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:

http://www.manuelabadia.com/blog/Per...5ceaf21cc.aspx

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:

http://www.manuelabadia.com/products/EODS_features.aspx

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,
Manu.

Apr 18 '06 #3
MC
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">
<Columns>
<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" />
</Columns>
</asp:GridView>
<asp:ObjectData Source ID="ObjectDataS ource1" runat="server"
OldValuesParame terFormatString ="original_{ }"
SelectMethod="g etInvalidItemBy News" UpdateMethod="e ditNews"
TypeName="Rx">
<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 =
original_cid;
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
MC
Here's output error. I really have no clue to what or where this error
resides.
Thanks...

[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)
+86
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)
+172
System.Web.UI.P age.ProcessRequ estMain(Boolean
includeStagesBe foreAsyncPoint, Boolean includeStagesAf terAsyncPoint)
+4900

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
MC
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.
MC

Apr 18 '06 #7
MC
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

2
6544
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 or Insert
7
5174
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... Thanks in advance! MC
0
3511
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,
0
1534
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. However, there are some columns in the DataGrid that should be invisible or read-only. When I set the...
4
12559
by: Tomasz | last post by:
Hello Developers, Here is interesting problem I just came across: how do I wire a GridView control programmatically? Here is my sample code using Object Data Source: protected void Page_Load(object sender, EventArgs e) { ObjectDataSource ods = new ObjectDataSource("MyTestTableAdapter",
5
4672
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 enter Line Editing mode. Is this a bug? Is there a workaround for this problem?
4
6064
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 object method to perform the update:
2
10845
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, maybe (?), in the last GridView
0
4268
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 rid of the "original" I would still have just "Parametername". I think most people user parameters...
0
2411
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:
0
8383
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8803
jinu1996
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8587
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7407
agi2029
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6210
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4384
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2792
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
2
1787
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.