0% found this document useful (0 votes)
43 views2 pages

SQL DataSource Exercise

The document provides instructions for creating an ASP.NET web application that displays product data from a SQL database using GridView and DetailsView controls. It describes how to: 1) Create an empty ASP.NET web site and add jQuery and Bootstrap libraries. 2) Create database tables for categories and products with a foreign key relationship. 3) Populate the GridView and DetailsView controls to display and manage the category and product data from the SQL tables. 4) Add links between pages to view categories on one page and associated products on another.

Uploaded by

Halimovic Almir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views2 pages

SQL DataSource Exercise

The document provides instructions for creating an ASP.NET web application that displays product data from a SQL database using GridView and DetailsView controls. It describes how to: 1) Create an empty ASP.NET web site and add jQuery and Bootstrap libraries. 2) Create database tables for categories and products with a foreign key relationship. 3) Populate the GridView and DetailsView controls to display and manage the category and product data from the SQL tables. 4) Add links between pages to view categories on one page and associated products on another.

Uploaded by

Halimovic Almir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

VEBA 7 RAD SA BAZOM sa SqlDataSource kontrolom, GridView, DetailsView

kontrole
1) Startujte Visual Studio 2012. File->New->Web Site

3)
4)
5)
6)

Izaberite ASP.Net Emty Web Site.


2) Instalirajte jquery i bootstrap sa:
Install-Package jquery
Instal-Package bootstrap
Dodajte Master stranicu preuzmite njen sadrzaj iz master.txt fajla. Ostavite samo prvi red vae
Dodajte Web Form stranicu i recite da je povezana sa Master stranicom.
U projekat dodajte bazu podataka.
Izvrite sledei skript na bazi
CREATE TABLE [dbo].[Kategorije]
(
[kategorijaID] INT NOT NULL PRIMARY KEY identity,
naziv_kategorije nvarchar(50)
)
CREATE TABLE [dbo].[proizvodi]
(
[proizvodID] INT NOT NULL PRIMARY KEY identity,
naziv_proizvoda nvarchar(100),
kategorijaID int,

cena decimal(18,2),
raspolozivost bit not null,
CONSTRAINT [FK_proizvodi_kategorije] FOREIGN KEY (kategorijaID) REFERENCES
[Kategorije]([kategorijaID])
)
U bazu ubacite neke probne podatke.
7) Dodajte GridView na stranicu. Udjite u meni sa dodatnim opcijama (pojavice se kada u
source-u pridjete miem mestu gde je otvoreni tag asp:GridView). Izaberite da hoete da
napravite novi Data source. Izaberite iz ponudjenih opcija ime baze koju ste napravili. Nakon
toga treba da izaberete tabelu iz koje hoete da prikaete podatke -> kategorije. I prodjite
kroz preostale korake.
8) setujte sledecu osobinu GridView-a CssClass="table table-striped"
9) ukljuite na gridview paging i pogledajte kako radi
10) ukljuite sorting, pa pogledajte kako radi
11) stanite na SqlDataSource pa izaberite configure data source pa next, pa otidjite u advanced i
izaberite upadate, delete.
12) uljucite na gridview-u editovanje i deletovanje
13) Ubacite i details view na stranicu pa omogucite sve operacije na njemu (insert, update, delete)
pa isprobajte kako radi
14) stanite na gridview i u dodatnim setovanjima, izaberite edit columns. Dodajte HyperLinkField,
bitno je da setujete sledece osobine:
DataNavigateUrlFields: kategorijaID
DataNavigateUrlFormatString: proizvod.aspx?kategorijaID={0}
DataTetField: naziv_kategorije
15) Izaberite opet GridView edit columns i obrisite kategorijaID, i naziv_kategorije kolone.
16) Dodajte novu stranicu proizvod.aspx poveite sa master stranicom. Dodajte u nju gridview i
sqldatasource. U sourcu izaberite da elite podatke iz proizvodi tabele i kliknite na where.
napravite sledeci upit select * from proizvodi where @kategorijaid=-1 or
kategorijaid=@kategorijaid. Za kategorijaID izaberite da je default value -1, i da vrednost
uzima iz query string-a ime parametra kategorijaid.
17) vratite se u master stranicu i promenite da imate dva linka. Jedan koji se zove kategorija i
pokazuje na default.aspx, i drugi koji se zove proizvodi i pokazuje na proizvodi.aspx

You might also like