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 7 2809
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
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.
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();
}
}
}
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
I think you should change OldValuesParameterFormatString="original_{}"
to OldValuesParameterFormatString="original_{0}".
Hope it helps,
Manuel Abadia.
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
THANK YOU!!!! I finally got some meaningful errors and in a split
second I got it fixed! 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...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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,...
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
| |
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...
|
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...
| |