473,509 Members | 12,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview + ObjectDatasource + 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 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

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

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

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

There's a bug in the ObjectDataSource that prevents it from working
properly if the current culture is "compatible" with the
InvariantCulture. 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
ObjectDataSource is to set your current culture to the InvariantCulture
but probably this is not what you want to do as you'll loose your
datetime and real formats.

You can use my ExtendedObjectDataSource that is a component with more
functionality than the ObjectDataSource:

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 ObjectDataSource 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="gridViewNews" runat="server"
AutoGenerateColumns="False" DataSourceID="ObjectDataSource1"
DataKeyNames="cid,rid">
<Columns>
<asp:CommandField ShowEditButton="True" >
</asp:CommandField>
<asp:BoundField DataField="cid" HeaderText="CID" ReadOnly="True"
SortExpression="cid" />
<asp:BoundField DataField="rid" HeaderText="RID" ReadOnly="True"
SortExpression="rid" />
<asp:BoundField DataField="controlvocabulary"
HeaderText="Thesaurus" ReadOnly="False"
SortExpression="controlvocabulary" HtmlEncode="false" />
<asp:BoundField DataField="title" HeaderText="Rx Title"
ReadOnly="True" SortExpression="title" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
OldValuesParameterFormatString="original_{}"
SelectMethod="getInvalidItemByNews" UpdateMethod="editNews"
TypeName="Rx">
<UpdateParameters>
<asp:Parameter Name="original_cid" Type="Int32" />
<asp:Parameter Name="original_rid" Type="Int32" />
<asp:Parameter Name="controlvocabulary" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>

[CLASS page with UPDATE method]:
public static void editNews(int original_cid, int original_rid, string
controlvocabulary, string title) {
using (SqlConnection connection = new
SqlConnection(ConfigurationManager.ConnectionStrin gs["OFHC-RX_RxConnectionString"].ConnectionString))
{
using (SqlCommand command = new SqlCommand("lex_EditNews",
connection)) {
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@contentid", SqlDbType.Int).Value =
original_cid;
command.Parameters.Add("@revisionid", SqlDbType.Int).Value
= original_rid;
command.Parameters.Add("@controledvocabvalue",
SqlDbType.NVarChar, 1000).Value = controlvocabulary;
int result = 0;
connection.Open();
result = command.ExecuteNonQuery();
connection.Close();
}
}
}

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.StringBuilder.FormatError() +54
System.Text.StringBuilder.AppendFormat(IFormatProv ider provider,
String format, Object[] args) +2834404
System.String.Format(IFormatProvider provider, String format,
Object[] args) +93

System.Web.UI.WebControls.ObjectDataSourceView.Mer geDictionaries(ParameterCollection
reference, IDictionary source, IDictionary destination, String
parameterNameFormatString) +229

System.Web.UI.WebControls.ObjectDataSourceView.Exe cuteUpdate(IDictionary
keys, IDictionary values, IDictionary oldValues) +2113
System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary
values, IDictionary oldValues, DataSourceViewOperationCallback
callback) +78
System.Web.UI.WebControls.GridView.HandleUpdate(Gr idViewRow row,
Int32 rowIndex, Boolean causesValidation) +1218
System.Web.UI.WebControls.GridView.HandleEvent(Eve ntArgs e, Boolean
causesValidation, String validationGroup) +853
System.Web.UI.WebControls.GridView.OnBubbleEvent(O bject source,
EventArgs e) +87
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.GridViewRow.OnBubbleEven t(Object source,
EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs
args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(Com mandEventArgs e)
+86
System.Web.UI.WebControls.LinkButton.RaisePostBack Event(String
eventArgument) +153

System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+172
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+4900

Apr 18 '06 #5
I think you should change OldValuesParameterFormatString="original_{}"
to OldValuesParameterFormatString="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
6531
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...
7
2809
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...
0
3494
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...
0
1525
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...
5
4665
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...
4
6032
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...
2
10835
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,...
0
4246
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...
0
2403
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...
0
7137
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...
0
7417
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...
1
7074
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...
0
5659
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,...
0
4734
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...
0
3219
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...
0
3210
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
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 ...
0
445
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...

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.