How do i modify the default update method for an asp.net datagrid with object data source to SQL Server backend.
Posted on 2009-02-13
Hey, first time question poster here, I've worked only a bit with asp.net and bringing datagrids out for managing sqlServer Data. So I am 'somewhat' comfortable with the various sheets and places which to find certain tags, etc. But I can tell very quickly that there is much for me to learn on it.
Here's the question:
I have a datagrid which is displaying table data, and have enabled Updating. I've set up all of the fields as item templates so that i could add an "Insert" row in the footerRow of the gridview.
-Everything is working wonderful at this point-
I decide to make 1 field no longer editable, which is usually accomplished by knocking out the <EditItemTemplate> tag and it's contents, or at the very least, change the contained textbox to simply a label. The reason i don't want this editible anymore is because i want to drive this field off of another one.
Name | Id | effective_dte | term_dte |.......
I can look the name up (which i already do on the insert method) so that when an ID# is typed into the footer row and inserted, it mines the Name from the name table.... it is however relevant and useful for the users to have this information displayed (and this field is just informational), i just don't want to rely on them for accuracy of it and figured why not just drive it off of the name table.
I have modified the update method to be this:
Set MyNameField = (SELECT NmeFld FROM MyNameTable WHERE IdFld = @IdParam)
, MyIdFld = @IdParam
, MyEffDte = @EffParam
, MyTrmDte = @TrmParam)
-The reason i do this is in case someone inadvertently types an incorrect Id# into the table, they can go back and edit the ID# which will refresh the contents of the name field (regardless of your agreement or lack thereof, it's the greater functionality rather than this specific case which is evading me and i seek and answer to)
Everything looks slick like it should work fine (just as it did when i pulled the same thing off for the Insert Method (which works perfect) but every time i go to update a record it throws this:
Exception Details: System.InvalidOperationException: ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Update' that has parameters: CLT_BSU, PGRM_EFFECTIVE_DTE, PGRM_TERMINATE_DTE, original_CLT_PGRM_NO, CLT_PGRM_NO, CLT_NAME.
(where CLT_BSU = MyIdFld, Pgrm_Effective_dte = MyEffDte, Pgrm_Terminate_dte = MyTrmDte, CLT_PGRM_NO is my PK field, CLT_NAME = MyNameFld)
-Keep in mind everything worked perfectly until i modified the update method. I've also pulled the <Parameter> tags out for CLT_NAME in my .aspx page in the update section and modified the .xsd page...
Any Idea where/why this would hang up here? (and why it worked fine for the insert Method?)