Misprivate.boun.edu.tr
Sample Project Using Northwind DatabasePrepare an aspx file for displaying categories table with images.Create categories.aspxSetup database from server explorer (Right click, add connection)Click categories table and dragEdit columnsDelete PictureUrl fieldAdd image fieldChange header text to photoChange dataimageurl field to pictureurlPrepare an aspx file for displaying products table with edit, delete and add featuresProduct Name: , TextBox, Button, Code: protected void Button1_Click(object sender, EventArgs e) { string sql1="INSERT INTO Products (ProductName) VALUES ('" + TextBox1.Text + "');"; AccessDataSource1.InsertCommand = sql1; AccessDataSource1.Insert(); AccessDataSource1.DataBind(); }Prepare an aspx file for displaying customers table (5 customers per page). Perform an add operation for “CustomerID” and “Company Name” with a check of null item.Customer ID: , TextBox1, Company Name: , TextBox2Add a label for messageAdd ImageButton, select addrecord.jpgWrite code: if ((TextBox1.Text != "") && (TextBox2.Text != "")) { System.Data.OleDb.OleDbConnection dbconn = new System.Data.OleDb.OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;Data Source=" +AppDomain.CurrentDomain.BaseDirectory + "/northwind.mdb"); dbconn.Open(); string SqlString = "Select * from Customers where CustomerID='" + TextBox1.Text + "'"; System.Data.OleDb.OleDbCommand dbcommand = new System.Data.OleDb.OleDbCommand(SqlString, dbconn); object cnt = dbcommand.ExecuteScalar(); if (cnt == null) { string sql1 = "INSERT INTO Customers (CustomerID,CompanyName) VALUES ('" + TextBox1.Text + "', '" + TextBox2.Text + "');"; AccessDataSource1.InsertCommand = sql1; AccessDataSource1.Insert(); AccessDataSource1.DataBind(); Label1.Text = ""; TextBox1.Text = ""; TextBox2.Text = ""; } else { Label1.Text = "Customer ID should be unique."; } } else { Label1.Text = "All fields are required"; } Add “CustomerID” as AAAAA. See that it is at the end of records. Configure datasource of gridview to add “order by” statement, so when new item added it will be sorted. Check with “AAAAB” CustomerID.Prepare an aspx file for filtering orders and order details tables. The filtering will include:According to shipcountry (by selected country) AND shippeddate (by selected year)Prepare a query (query1) to get OrderID, ShipCountry from Orders table, UnitPrice and Quantity from OrderDetails table, and add Year field for Year([shippeddate]). Add a relation for OrderID.Add orders.aspxAdd Gridview for query1Autoformat, select a templateSelect Country:, add dropdown list, add datasource, write SQL statement as:SELECT DISTINCT [ShipCountry] FROM [Query1]Click Enable AutoPostbackAdd code: protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { string sql2 = "SELECT * FROM Query1 WHERE ShipCountry ='" + DropDownList1.SelectedValue.ToString() + "' AND Year =" + DropDownList2.SelectedValue; AccessDataSource1.SelectCommand = sql2; AccessDataSource1.DataBind(); }Select Year:, add dropdown list, add datasourceSELECT DISTINCT [Year] FROM [Query1]Click Enable AutoPostbackAdd code: protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { string sql2 = "SELECT * FROM Query1 WHERE ShipCountry ='" + DropDownList1.SelectedValue.ToString() + "' AND Year =" + DropDownList2.SelectedValue; AccessDataSource1.SelectCommand = sql2; AccessDataSource1.DataBind(); }On the same file display the total sales (unit price * quantity) as label.Add template field Total to gridview and add code for TemplateField: <ItemTemplate> <asp:Label ID="lbltotal" runat="server" Text='<%# Convert.ToDouble(Eval("Quantity")) * Convert.ToDouble(Eval("UnitPrice")) %>' ></asp:Label></ItemTemplate>Prepare orderdetails.aspx file for displaying order details table (5 records per page) and selected product info.Add Gridview for orderdetails table, click “Enable Selection”Add Gridview for products tableDouble click “Select” and write code: protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = GridView1.SelectedRow; // Get prodcutID from the selected row. string rowval = row.Cells[2].Text; string sql = "Select * from products where ProductID=" + rowval; AccessDataSource2.SelectCommand = sql; AccessDataSource2.DataBind(); }Create a menu in default.aspx with buttons for new files created.Cookie exampleAdd panel for buttons and code for default.aspx to add and delete cookie(v=vs.100).aspx protected void Page_Load(object sender, EventArgs e) { if (Request.Cookies["Customer"] == null) { // Add cookie Response.Cookies["Customer"]["Name"] = "BKB"; Response.Write("Cookie was deleted, refresh for menu"); Panel1.Visible = false; } else { Panel1.Visible = true; Response.Write("Welcome BKB"); // Delete cookie Response.Cookies["Customer"].Expires = DateTime.Now.AddDays(-1d); } } ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- minecraft edu edition
- minecraft edu download free
- minecraft edu edition recipes
- minecraft edu mod download
- michigan tr 34
- tr 34 certification
- tr price funds historical performance
- tr 34 michigan form
- tr 34 certification michigan
- tr 34 blank certification form
- form tr 30 15 3
- form tr 30 15 3 certificate to terminate existence