0

大家好,我正在使用 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;
  }
4

1 回答 1

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();
  }

谢谢

于 2012-12-10T10:55:13.857 回答