I have been given the task to create a shop website that allows users to look at DVDs that are available in a shop page and then when they click on one they will be taken to a details page which will give more information dynamically about the DVD. I also have been given ac# file which contains a class called DVD. I have so far got the webpages which I made in ASP.NET and that was easy enough to pull everything from the database and it all works fine but that has nothing to do with the DVD.cs file.
Am I missing something obvious? I have to use this file which I will post below :
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DVDs
{
class DVD
{
public string Title
{
get;
set;
}
public int Price
{
get;
set;
}
public int YearReleased
{
get;
set;
}
public string Desc
{
get;
set;
}
public DVD(string title, int price, int yearReleased, string desc)
{
Title = title;
Price = price;
YearReleased = yearReleased;
Desc = desc;
}
protected bool Save()
{
//add code to save to the database
return true;
}
protected bool Load()
{
//add code to load from the database
return true;
}
}
}
Can someone please explain how I use these variables to link between the database and the .aspx file?
All help would be appreciated thanks
EDIT : Code tried so far
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (this.IsPostBack)
{
PageAsyncTask pat = new PageAsyncTask(BeginAsync, EndAsync, null, null, true);
RegisterAsyncTask(pat);
}
}
private IAsyncResult BeginAsync(object sender, EventArgs e, AsyncCallback cb, object state)
{
DVD dvd = new DVD();
}
either make it with MVC as it is already told or take a look at ASP.Net binding to link your DVD object to the UI.
This could be a good starting point: http://support.microsoft.com/kb/307860
使用实体框架将帮助您以非常简单的方式将类连接到数据库,但是要将类属性链接到ASP.NET .aspx文件,可以使用session["key"] = value
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.