How to populate gridview with mysql?

asp.net, c#, gridview, mysql

Solution

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.Common;
using MySql.Data.MySqlClient;
using System.Data.SqlClient;
using System.Windows.Forms;
using System.Data;

public partial class viewAdmin : System.Web.UI.Page
{
    String MyConString = "SERVER=localhost;" +
                "DATABASE=databasename;" +
                "UID=root;" +
                "PASSWORD=;";
protected void Page_Load(object sender, EventArgs e)
{

        MySqlConnection conn = new MySqlConnection(MyConString);
        MySqlCommand cmd = new MySqlCommand("SELECT * FROM tablename;", conn);
        conn.Open();
        DataTable dataTable = new DataTable();
        MySqlDataAdapter da = new MySqlDataAdapter(cmd);

        da.Fill(dataTable);


        GridVIew.DataSource = dataTable;
        GridVIew.DataBind();
}

}

Problem

I just know how to populate gridview with `asp:SqlDataSource` But I have a column of `TemplateField` in my `gridview`, when I need modify my SQL for alter grid content, I lose my `TemplateField`, so I think learn populate my `gridview` with C# Someone can teach me or give me some tutorial?

Original source