using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using MySql.Data.MySqlClient;
namespace WebApp
{
public partial class WebForm2 : System.Web.UI.Page
{
ClassConnectDB Connect = new ClassConnectDB();
protected void Page_Load(object sender, EventArgs e)
{
Connect.ConnectDB();
BindData();
Connect.DisConnectDB();
}
void BindData()
{
String strSQL;
strSQL = "SELECT * FROM student";
MySqlCommand objCmd;
MySqlDataReader dtReader;
objCmd = new MySqlCommand(strSQL,Connect.objConn);
dtReader = objCmd.ExecuteReader();
//*** BindData to DataGrid ***//
StudentGridView.DataSource = dtReader;
[font=Verdana]//เออเรอตรงนี้ตอนรันครับ[/font]
StudentGridView.Columns[0].HeaderText = "รหัสสินค้า";//กำหนด header
StudentGridView.DataBind();
dtReader.Close();
dtReader = null;
}
}
}