2012-06-19 114 views
1

大家好我正在用objectdatasource創建更新功能。實際上它工作正常,直到我沒有更改UpdateMethod的參數。我有兩個參數,但它期待三個參數。給我下面的錯誤。Objectdatasource更新問題

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; 
    } 
+0

你的錯誤消息說,你需要在你的更新方法三個參數。您錯過了CONFIG_VALUE參數。 –

+0

@BogdanRotund:我不想要第三個參數。即使在業務邏輯中,我只有兩個參數。 – user968441

+0

檢查您的UpdatePagedDataSet具有多少個參數。 –

回答

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

感謝