You need to change the SqlDbType
on Inserting
:
protected void SqlDataSource1_Inserting(object sender,
SqlDataSourceCommandEventArgs e) {
SqlParameter insertedKey =
e.Command.Parameters["@PKComplexID"] as SqlParameter;
insertedKey.SqlDbType = SqlDbType.UniqueIdentifier;
}
References
http://forums.asp.net/t/1712791.aspx/1:
Object is incorrect type for uniqueidentifier field. But unfortunately
we do not have uniqueidentifier in VisualStudio designer. So its
giving you type Object. Neither you can make it uniqueidentifier which
throws you exception. So you have to change this parameter type form
code behind file in dataSource_Inserting event. Be sure its Inserting
event. There you can get any parameter and set the uniqueidentifier
fields type to uniqueidentifier.
GUIDs and DataSource Controls