Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on [email protected] for help. Thanks :)
Hello All, This is just a friendly reminder to read the Forum Charter where you wish to post before posting in it. :)

C# shopping basket, trying to remove an item...

12345679»

Comments

  • Closed Accounts Posts: 7,097 ✭✭✭ Darragh29


    Thanks a mil for that... What I'm also trying to do is use different product tables in my DB to product different dropdown lists depending on what page a user is on. Say they are on a page on the site for car engines, then the dropdown lists (_Make, _Model, _EngineType) and the parts available for that particular product are populated from the CarEngine table in my DB. If the user moves onto another page say Clutches, then the dropdown lists and parts associated with that product are populated from the Clutch Table.

    Before I go into this, is this actually possible??? I'm hoping its just a matter of copying the code so far and creating a new method, some new variables and stored procedures, for each new product table. I just wanted to check with you that it was reasonably possible with the solution before I jumped into it???

    Another way of doing the above would be to add a fourth dropdown list to deal with this but I'd like to go at it the first way if it was handy enough...


  • Registered Users Posts: 2,931 ✭✭✭ Ginger


    Actually its a bit easier than that :)

    Create a new table called say Type and create it with an Id field int auto incrementing and a Name field which is varchar(50) and primary key the id field.

    Add a few rows say clutches, exhausts whatever

    Now add a new field to Product called TypeID and make it an int...

    You can then assign a typeid to each product

    Now all you need to do is change the GetAllProducts in both Business and Data to accept an int and change the storedprocs for those functions to accept an int and select based on typeid (you dont need to return it)

    What happens now, is you select your products by typeid so that you only get back the set that matches for example clutches.. No changes required for the subcat and spec dropdowns at all


  • Closed Accounts Posts: 7,097 ✭✭✭ Darragh29


    Ginger wrote: »
    Sorry mate was meant to come back to this

    It doesnt need to be that complex..

    You can use a simple <a href="ViewLargeImage.aspx?=<%# ((Product)Container.DataItem).Image_Id %>"><img src="image"></a>

    You should use a bool, and an id, and path to the image (or if you are storing the image in the database, use a bytes[] )

    I'm getting an unexpected error on this... I added just one line of code to my Default.aspx page,

    <td><%# ((Product)Container.DataItem).Description %></td>
    <td>€<%#((Product)Container.DataItem).Cost.ToString(CultureInfo.InvariantCulture) %></td>
    <td><%# ((Product)Container.DataItem).Image_Name %> </td>

    I added one line to the Product.cs file under Common/Entities:

    public int Id { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public double Cost { get; set; }
    public string Image_Name { get; set; }

    And I'm getting an error:

    Compiler Error Message: CS1061: 'ShoppingCart.Common.Entities.Product' does not contain a definition for 'Image_Name' and no extension method 'Image_Name' accepting a first argument of type 'ShoppingCart.Common.Entities.Product' could be found (are you missing a using directive or an assembly reference?)

    in relation to the code at:
    <td><%# ((Product)Container.DataItem).Image_Name %> </td>

    The weird thing is I added a variable last week into the same two pages and I didn't get this compilation error... This has me confused, I haven't really tried to do anything other than add a variable and it won't even compile now???


  • Registered Users Posts: 2,931 ✭✭✭ Ginger


    Build common project first


  • Closed Accounts Posts: 7,097 ✭✭✭ Darragh29


    Ginger wrote: »
    Build common project first

    No luck... It'll compile locally but not when I upload it to the web server.


  • Advertisement
  • Registered Users Posts: 2,931 ✭✭✭ Ginger


    Sounds like the latest assemblies arent being uploaded...


  • Closed Accounts Posts: 7,097 ✭✭✭ Darragh29


    That's what's happening, it's like as if when I upload the file to the webserver, it isn't being changed.

    I tried changing the variable name locally by one character so in my Product.cs file it's called _Image1 and in my Default.aspx file I've left it at _Image and then when I try to compile, I get the same error that I'm getting when I try to load the page on the remote webserver.

    I'm just going to try uploading the whole solution again.


  • Closed Accounts Posts: 7,097 ✭✭✭ Darragh29


    Uploading the whole solution again seems to have resolved the issue. Weird! It's going to be a long day trying to get this working and having to upload the whole solution every time I want to add a variable! ;-)


  • Registered Users Posts: 2,931 ✭✭✭ Ginger


    Actually what needs to upload is the files in the bin directory... otherwise those assemblies dont get updated..

    Because you are using a multiple project solution, you will see in the bin directory in your web application there is a couple of dlls and these must be uploaded when you change anything in the underlying sttructure. So if you make a change in common, you need to upload the new common.dll file..


  • Closed Accounts Posts: 7,097 ✭✭✭ Darragh29


    That's great to know that. I wasn't uploading that file yesterday so that must have been the problem.


  • Advertisement
  • Closed Accounts Posts: 7,097 ✭✭✭ Darragh29


    Just when I thought things couldn't get anymore complicated or messy with this, the hard drive has died in my local development server. The files are still on my remote dev web server but I'm using FTP Commander (Freeware), to transfer the files, when I log into the remote server to try to download the solution so I can begin working in it again, I can't see the folders: Business, Common and DataAccess. When I log into the control panel and view the files there through the File Manager tool, they are there. Just wondering why I can't see them using an FTP application?


Advertisement