string mysqlcomnnection = Convert.ToString(ConfigurationManager.AppSettings["connection"]);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridview();
}
}
private void BindGridview()
{
MySqlConnection con = new MySqlConnection(mysqlcomnnection);
string CommandText = "Select userid as UserID, firstname as FirstName,lastname as LastName from users";
MySqlCommand cmd = new MySqlCommand(CommandText, con);
MySqlDataAdapter sda = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
gvUsers.DataSource = dt;
gvUsers.DataBind();
}