object data source

E

eagle

I have a grid with an object datasource; selecting and populating the grid
works fine. I want to delete an item in the grid. How can I find out the
value of the parameters that are getting passed to my method? Or how can I
populate these parameters with the correct values? When I debug the method,
there are no values getting passed to it. The datasource and grid are as
follows:

GRIDVIEW:

<asp:GridView ID="gvProducts" runat="server" AutoGenerateColumns="False"
DataSourceID="oDSProducts" EmptyDataText="No products found">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True"
EditImageUrl="~/Images/Edit.gif" DeleteImageUrl="~/Images/trash.gif"
CancelImageUrl="~/Images/undo.gif" SelectImageUrl="~/Images/arrow-right.gif"
UpdateImageUrl="~/Images/Update.gif" ButtonType="Image" SelectText=""
ShowSelectButton="True" />
<asp:TemplateField InsertVisible="False" SortExpression="ID">
<ItemTemplate>
<asp:Label ID="Label2" visible="false" runat="server" Text='<%#
Bind("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="ItemNumber" HeaderText="Item Number"
SortExpression="ItemNumber" />
<asp:BoundField DataField="Productname" HeaderText="Product Name"
SortExpression="Productname" />
<asp:BoundField DataField="WholeSalePrice" HeaderText="Wholesale"
SortExpression="WholeSalePrice" DataFormatString="{0:c2}" >
<ItemStyle HorizontalAlign="Right" />
</asp:BoundField>
<asp:BoundField DataField="Retailprice" HeaderText="Retail"
SortExpression="Retailprice" DataFormatString="{0:d2}" >
<ItemStyle HorizontalAlign="Right" />
</asp:BoundField>
</Columns>
</asp:GridView>


DATASOURCE:
<asp:ObjectDataSource ID="oDSProducts" runat="server"
SelectMethod="GetProductList"
TypeName="cls.Product" DeleteMethod="DeleteProduct">
<SelectParameters>
<asp:ControlParameter ControlID="gvCategories"
Name="ProductCategoryID" PropertyName="SelectedValue" Type="Int32"
DefaultValue="1" />
<asp:parameter Name="SectionID" DefaultValue="1" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:parameter Name="ID" />
<asp:parameter Name="ItemNumber" />
</DeleteParameters>
</asp:ObjectDataSource>


DELETE METHOD:
Public Shared Sub DeleteProduct(ByVal ID as String)

Try
Dim _DL as New cls
Dim qry as String = "ProductDelete '" & ID & "'"
_DL.ExecuteNonQuery(qry)
Catch ex As Exception
Throw New Exception("Delete Product: " & ex.Message)
End Try
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top