object data source

Discussion in 'ASP .Net' started by eagle, Jul 9, 2007.

  1. eagle

    eagle Guest

    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
     
    eagle, Jul 9, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?S2h1emVtYQ==?=

    Object Data Source and Custom Business Object

    =?Utf-8?B?S2h1emVtYQ==?=, Jun 27, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    786
    =?Utf-8?B?S2h1emVtYQ==?=
    Jun 27, 2005
  2. Gummy
    Replies:
    1
    Views:
    660
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jan 3, 2006
  3. Siva
    Replies:
    1
    Views:
    1,316
    Jeff Dillon
    Apr 24, 2006
  4. Author Tarun Tyagi
    Replies:
    0
    Views:
    718
    Author Tarun Tyagi
    Dec 29, 2004
  5. Allan Ebdrup
    Replies:
    2
    Views:
    477
    Allan Ebdrup
    Oct 6, 2006
Loading...

Share This Page