Wrox Programmer Forums
|
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 3rd, 2007, 09:45 AM
Authorized User
 
Join Date: Jul 2006
Posts: 40
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter5 ObjectDataSource

Hi..

I have two questions:
The first:In chapter 5 page 244 (ManageCategories page)the objectdatasource doesn't have InsertParameters even the InsertCategory method has parameters.

The second:In chapter 5 page 251 (ListingArticles user control)the objectdatasource has a delete method which has a delete parameter(id).How was it(the delete parameter) set and where?.


 
Old March 4th, 2007, 12:46 PM
plb plb is offline
Authorized User
 
Join Date: Jan 2007
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In answer to the second question:

There is the PROC:
Code:
ALTER PROCEDURE dbo.tbh_Articles_DeleteCategory
(
    @CategoryID int
)
AS

DELETE tbh_Categories WHERE CategoryID = @CategoryID
Which is called from the the DAL page
 "...DAL.SqlClient.SqlArticlesProvider" where the PROC is invoked.

Code:
/// <summary>
/// Deletes a category
/// </summary>
  public override bool DeleteCategory(int categoryID)
      {
         using (SqlConnection cn = new SqlConnection(this.ConnectionString))
         {
            SqlCommand cmd = new SqlCommand("tbh_Articles_DeleteCategory", cn);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@CategoryID", SqlDbType.Int).Value = categoryID;
            cn.Open();
            int ret = ExecuteNonQuery(cmd);
            return (ret == 1);               
    }
}
Which is called from the BLL code in
"...BLL/Articles/Category"

Code:
     /// <summary>
      /// Deletes an existing category
      /// </summary>
      public static bool DeleteCategory(int id)
      {
         bool ret = SiteProvider.Articles.DeleteCategory(id);
         new RecordDeletedEvent("category", id, null).Raise();
         BizObject.PurgeCacheItems("articles_categor");
         return ret;
      }


The BLL code is addressed in the ObjectDataSource in the
 "...Admin/ManageCategories.aspx" page.

  
Code:
<asp:ObjectDataSource ID="objAllCategories" runat="server" SelectMethod="GetCategories"
Code:
      TypeName="MB.TheBeerHouse.BLL.Articles.Category" DeleteMethod="DeleteCategory">
   </asp:ObjectDataSource>


I think that's how it works.


http://weboperahouse.com
 
Old March 5th, 2007, 01:15 AM
Authorized User
 
Join Date: Jul 2006
Posts: 40
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thank you for your reply but this not what I asked for.

Iam asking about setting the DeleteParameter for the DeleteMethod in the User Interface(in the ObjectDataSource).

And my first question is about the InsertParameters for the InsertMethod also in the User Interface(in the objectDataSource).






Similar Threads
Thread Thread Starter Forum Replies Last Post
CH5 ObjectDataSource nabeelalkaff BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 March 8th, 2007 01:19 PM
Problem with ObjectDataSource... veeruu ASP.NET 2.0 Professional 0 March 2nd, 2007 07:45 AM
What does ObjectDataSource.Update do? Aaron Edwards ASP.NET 2.0 Basics 1 November 27th, 2006 05:40 PM
Formview with ObjectDataSource rturner003 ASP.NET 2.0 Professional 3 November 1st, 2006 06:17 AM
ObjectDataSource and Wildcards pipelineconsulting ASP.NET 2.0 Professional 1 October 19th, 2006 09:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.