簡體   English   中英

使用ASP.NET,C#和SQL

[英]Working with ASP.NET, C# and SQL

我的任務是創建一個商店網站,使用戶可以查看商店頁面中的DVD,然后單擊它們時,將帶他們到詳細信息頁面,該頁面將動態提供有關DVD的更多信息。 我還得到了一個包含名為DVD的類的ac#文件。 到目前為止,我已經獲得了我在ASP.NET中制作的網頁,並且很容易將所有內容從數據庫中提取出來,並且一切正常,但與DVD.cs文件無關。

我是否缺少明顯的東西? 我必須使用此文件,該文件將在下面發布:

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;
    }
}
}

有人可以解釋一下我如何使用這些變量在數據庫和.aspx文件之間進行鏈接嗎?

所有幫助將不勝感激謝謝

編輯 :到目前為止,代碼已嘗試

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();
}

要么使用已被告知的MVC進行制作,要么查看ASP.Net綁定以將DVD對象鏈接到UI。

這可能是一個很好的起點: http : //support.microsoft.com/kb/307860

使用實體框架將幫助您以非常簡單的方式將類連接到數據庫,但是要將類屬性鏈接到ASP.NET .aspx文件,可以使用session["key"] = value

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM