OleDbConnection objConn; OleDbCommand objCmd; double sumTotal; public void Page_Load(object sender, EventArgs e) { string strConnString = null; strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("database/mydatabase.mdb") + ";"; objConn = new OleDbConnection(strConnString); objConn.Open(); BindData(); } public void BindData() { string strSQL = null; strSQL = "SELECT * FROM customer"; OleDbDataReader dtReader = default(OleDbDataReader); objCmd = new OleDbCommand(strSQL, objConn); dtReader = objCmd.ExecuteReader(); //*** BindData to GridView ***' myGridView.DataSource = dtReader; myGridView.DataBind(); dtReader.Close(); dtReader = null; } public void Page_UnLoad() { objConn.Close(); objConn = null; } private void myGridView_RowDataBound(object sender, GridViewRowEventArgs e) { //*** CustomerID ***' Label lblCustomerID = (Label)e.Row.FindControl("lblCustomerID"); if ((lblCustomerID != null)) { lblCustomerID.Text = e.Row.DataItem("CustomerID"); } //*** Email ***' Label lblName = (Label)e.Row.FindControl("lblName"); if ((lblName != null)) { lblName.Text = e.Row.DataItem("Name"); } //*** Name ***' Label lblEmail = (Label)e.Row.FindControl("lblEmail"); if ((lblEmail != null)) { lblEmail.Text = e.Row.DataItem("Email"); } //*** CountryCode ***' Label lblCountryCode = (Label)e.Row.FindControl("lblCountryCode"); if ((lblCountryCode != null)) { lblCountryCode.Text = e.Row.DataItem("CountryCode"); } //*** Budget ***' Label lblBudget = (Label)e.Row.FindControl("lblBudget"); if ((lblBudget != null)) { lblBudget.Text = Strings.FormatNumber(e.Row.DataItem("Budget"), 2); } //*** Used ***' Label lblUsed = (Label)e.Row.FindControl("lblUsed"); if ((lblUsed != null)) { lblUsed.Text = Strings.FormatNumber(e.Row.DataItem("Used"), 2); } sumTotal = sumTotal + e.Row.DataItem("Used"); //*** Total ***' Label lblTotal = (Label)e.Row.FindControl("lblTotal"); if ((lblTotal != null)) { lblUsed.Text = Strings.FormatNumber(sumTotal, 2); } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง