Objectdatasource更新问题

时间:2012-06-19 13:39:13

标签: asp.net entity-framework objectdatasource

大家好我正在使用objectdatasource创建更新功能。实际上它工作正常,直到我没有更改UpdateMethod的参数。我有两个参数但它期望三个参数。给我低于错误。

 ObjectDataSource 'ODSConfig' could not find a non-generic method 'UpdatePagedDataSet' that has parameters: CONFIG_VALUE, configKey, configValue.

C#代码:

protected void ODSConfig_Updating(object sender, ObjectDataSourceMethodEventArgs e)
  {
    TextBox val = (TextBox)GVConfig.Rows[GVConfig.EditIndex].Cells[2].Controls[0];
    Parameter objKeyConfig = new Parameter("configKey", DbType.String, GVConfig.Rows[GVConfig.EditIndex].Cells[1].Text);
    Parameter objKeyValueConfig = new Parameter("configValue", DbType.String, val.Text);
    e.InputParameters["configKey"] = objKeyConfig.DefaultValue;
    e.InputParameters["configValue"] = objKeyValueConfig.DefaultValue;
  }

1 个答案:

答案 0 :(得分:1)

添加参数后,只需添加ODSConfig.Update();

在此之后,您的代码将如下所示:

protected void ODSConfig_Updating(object sender, ObjectDataSourceMethodEventArgs e)
  {
    TextBox val = (TextBox)GVConfig.Rows[GVConfig.EditIndex].Cells[2].Controls[0];
    Parameter objKeyConfig = new Parameter("configKey", DbType.String, GVConfig.Rows[GVConfig.EditIndex].Cells[1].Text);
    Parameter objKeyValueConfig = new Parameter("configValue", DbType.String, val.Text);
    e.InputParameters["configKey"] = objKeyConfig.DefaultValue;
    e.InputParameters["configValue"] = objKeyValueConfig.DefaultValue;
ODSConfig.Update();
  }

感谢