Exception "Object must implement IConvertible" for multiple-field DataKeyNames in a GridVi

Exception "Object must implement IConvertible" for multiple-field DataKeyNames in a GridVi

am 08.04.2008 23:41:25 von dan

Hi,

I've been using a GridView for some time but this is the first time I need
to delete a row in the grid whose primary key consists of 2 fields (table
columns). I have a table with primary key set to c1,c2 where c1 is a
uniqueidentifier and c2 is int.

The DataKeyNames in the gridview is defined as follows:
DataKeyNames="c1,c2".

I have a ObjectDataSource defined with following delete params:





The ods is mapped to a bll's method Delete(string, int). Unfortunately the
method never gets called.

I attached RowDeleting event handler to the gridview to see the content of
GridViewDeleteArgs.Keys. The dictionary looks fine there, including key
names and values.


Partial stack dump of the exception that I get afterwards:

[InvalidCastException: Object must implement IConvertible.]
System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider) +2561730
System.Web.UI.WebControls.Parameter.GetValue(Object value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges) +264
System.Web.UI.WebControls.ObjectDataSourceView.MergeDictiona ries(ParameterCollection
reference, IDictionary source, IDictionary destination, String
parameterNameFormatString) +439
System.Web.UI.WebControls.ObjectDataSourceView.ExecuteDelete (IDictionary
keys, IDictionary oldValues) +846
System.Web.UI.DataSourceView.Delete(IDictionary keys, IDictionary
oldValues, DataSourceViewOperationCallback callback) +75
[...]

Could someone please let me know how to troubleshoot this?
Thanks,