Skip to content Skip to sidebar Skip to footer

Create Functions For Html Hyperlinks To Query Database

i have created a web application in asp.net with C# and MySql Database at the backend called simple online shopping, I have created a cascading dropdown horizontal navigation menu

Solution 1:

Use Repeater to render list of links on your page. Add query string value like ShowProduct.aspx?id=1 to every link.

On ShowProduct Page, use linq to retrieve data from DB:

using(DataContext db = new DataContext())
{
    int id = Convert.ToInt32(Request.QueryString["id"]);
    var product = db.products.Where(p => p.id = id).FirstOrDefault();
    if(product != null)
    {
        //do your job here with product data
    }
}

Post a Comment for "Create Functions For Html Hyperlinks To Query Database"