Skip to content

Error: Procedure or function ‘asp_DeleteActivity’ expects parameter ‘@UserID’, which was not supplied.

August 5, 2010
tags:

When there is a GridView bound column with the same name of a SessionParameter (“UserID” like in the example below), the Delete command returns wierd error “Procedure or function ‘asp_DeleteActivity’ expects parameter @UserID, which was not supplied“. When I changed the name of GridView Datafield of “UserId” to “By”, it started working again. Seems like a bug in .NET though not sure. (Visual Studio 2010, Windows 7)

GridView ID="GridView_Activity" runat="server" DataSourceID="SqlDataSource_Activity" DataKeyNames="ID" >

<Columns>
  CommandField ShowDeleteButton="True" ShowEditButton="True" />
  BoundField DataField="Date0" HeaderText="Date0" SortExpression="Date0"
  HtmlEncode="False" DataFormatString="{0:yyyy-MM-dd HH:mm:ss}" />
  BoundField DataField="LotNumber" HeaderText="LotNumber" SortExpression="LotNumber" />
  BoundField DataField="EventName" HeaderText="EventName" SortExpression="EventName" />
  BoundField DataField="UserID" HeaderText="UserID" SortExpression="UserID" />
  BoundField DataField="LocationName" HeaderText="Location" SortExpression="LocationName" />
  BoundField DataField="Remark" HeaderText="Remark" SortExpression="Remark" />
  BoundField DataField="ID" HeaderText="ID" ReadOnly="true" Visible="false" />
</Columns>
</asp:GridView>
SqlDataSource ID="SqlDataSource_Activity" runat="server" ConnectionString=<!--ConnectionStrings:ConnectionStringMain -->"
  DeleteCommand="[asp_DeleteActivity]" DeleteCommandType="StoredProcedure"
  InsertCommand="[asp_InsertActivity]" InsertCommandType="StoredProcedure"
  SelectCommand="[asp_SelectActivity]" SelectCommandType="StoredProcedure" >
   <DeleteParameters>
  SessionParameter Name="UserID" SessionField="userid" Type="String" />
  ControlParameter Name="ID" ControlID="GridView_Activity" PropertyName="SelectedValue" Type="Int32" />
   </DeleteParameters>
</asp:SqlDataSource>
Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: