Aspnetmaker generates the edit page from the selected table, however the error occurs when we include the following code in the Row Updated event:
table schema
TABLE [dbo].[TAHubs](
[IDHub] [int] IDENTITY(1,1) NOT NULL,
[Regional] [smallint] NULL,
[Hub] [nvarchar](30) NULL,
[Gestor] [smallint] NULL,
[Responsavel] [smallint] NULL,
CONSTRAINT [PK_TAHubs] PRIMARY KEY CLUSTERED
// Row Updated event
public void Row_Updated(Dictionary<string, object> rsold, Dictionary<string, object> rsnew) {
//Log("Row Updated");
string sql = "UPDATE TPPolos SET ";
if (String.IsNullOrEmpty(Convert.ToString(rsnew["Regional"]))) {
sql += "IDRegional = NULL";
} else {
sql += "IDRegional = " + Convert.ToString(rsnew["Regional"]);
}
if (String.IsNullOrEmpty(Convert.ToString(rsnew["Gestor"]))) {
sql += ",Gestor = NULL";
} else {
sql += ",Gestor = " + Convert.ToString(rsnew["Gestor"]);
}
if (String.IsNullOrEmpty(Convert.ToString(rsnew["Responsavel"]))) {
sql += ",Responsavel = NULL";
} else {
sql += ",Responsavel = " + Convert.ToString(rsnew["Responsavel"]);
}
sql += " WHERE IDHub = "+ Convert.ToString(rsnew["IDHub"]);
Execute(sql);
}
Error:
An unhandled exception occurred while processing the request.
KeyNotFoundException: The given key 'IDHub' was not present in the dictionary.
System.Collections.Generic.Dictionary<TKey, TValue>.get_Item(TKey key)