views:

22

answers:

2

Hi all,

I have defined the following in my gridview markup (simplified):

<asp:GridView ID="grvReport" runat="server" DataSourceID="odsReport" 
                AutoGenerateColumns="False" DataKeyNames="EntryDate,EmployeeNumber">

Then I define my datasource's update parameters as such:

<UpdateParameters>                                
                <asp:Parameter Name="ID" Type="Int32" />
                <asp:Parameter Name="IsJustified" Type="Boolean" />
                <asp:Parameter Name="Comment" Type="String" />                
                <asp:Parameter Name="LastEditor" Type="String" />     
 </UpdateParameters>

But when trying to update I get an error saying

could not find a non-generic method 'Update' that has parameters: ID, IsJustified, Comment, LastEditor, EntryDate, EmployeeNumber.

Can I avoid having the fields under DataKey coming up as parameters for my methods?

NOTE: I can work around this by simply modifying my method's parameters and adding the extra values coming from the Gridview and doing nothing with them but it would be nice to have a way to avoid these values even being sent at all.

Thanks in advance,
EtonB.

A: 

I think there is no workaround. Microsoft recognized this issue and says it will be solved in a next version. Check here for more info: https://connect.microsoft.com/VisualStudio/feedback/details/260674/generated-default-update-method-in-datatableadapter-in-a-typed-dataset-shouuld-not-update-primary-key.

Pieter
A: 

Data key names represent the primary key to the data you're updating, so I wouldn't think you could/should avoid having them in the update method. If the ID is is truly the primary key, then it should be listed under your data key names instead. Else your update method should take the EntryDate and EmployeeNumber as a parameter instead of ID.

James B