Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

pws vs iis vs apache, Trap timeout pdksh, nu vot, WWWXXXAPC, wwwxxxapc, WWWXXXAPC, WWWXXXAPC, WWWXXXAPC, WWWXXXAPC, iis is shit



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

Posted on 2008-04-08 23:41:25 by dan


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:

I have a ObjectDataSource defined with following delete params:
<asp:Parameter Name="c1", Type="String" />
<asp:Parameter Name="c2" Type="Inte32" />

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?

Report this message