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

D

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:
<DeleteParameters>
<asp:parameter Name="c1", Type="String" />
<asp:parameter Name="c2" Type="Inte32" />
<DeleteParameters>

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.MergeDictionaries(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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top