You have several obvious errors in the code.
1. your query is of type string so this line
for (int i = 0; i < query.Count(); i++)
will loop for each character in the query. You need dt.rows.count here.
2. you create new column
DataColumn dc = new DataColumn(dt.Rows[i].ToString());
but you don't specify the item to be read. You call ToString on the whole row which by default gives back the type (System.Data.DataRow) which you set as column name.
3. you are not adding that column into datatable.
This should be your final code:
public void load(object sender, EventArgs e)
{
string query = "USE db_compiler SELECT Column_Name FROM tbl_field WHERE Table_Name='pak'";
SqlCommand cmd = new SqlCommand(query, cnn);
DataTable dt = new DataTable();
SqlDataAdapter adp = new SqlDataAdapter(cmd);
DataTable table = new DataTable();
cnn.Open();
cmd.ExecuteNonQuery();
adp.Fill(dt);
for (int i = 0; i < dt.Rows.Count(); i++)
{
DataColumn dc = new DataColumn(dt.Rows[i].Item["Column_Name "].ToString());
dt.Columns.Add(dc);
}
DataRow r = table.NewRow();
GridView1.DataSource = table;
GridView1.DataBind();
cnn.Close();
}