在C#datagrid中显示set header

时间:2013-12-01 21:04:29

标签: c# data-binding

我已将数据网格设置为显示标题,然后设置了set列的标题,但它们未显示。 我错过了一些简单的东西吗?

 public void Hall_Of_Fame()
    {
        {  
            using (MySqlDataAdapter da = new MySqlDataAdapter("SELECT c.FirstName,c.LastName,c.Country,c.Specie,c.Donation_Pound,c.Donation_Euro,c.Donation_Lui FROM Customer c INNER JOIN Animals a ON c.Specie=a.Specie AND c.Country=a.Country WHERE c.Donation_Pound > a.Price  OR c.Donation_Euro > a.Price OR c.Donation_Lui > a.Price", cs))
            {
                da.Fill(dt);
            }
        }
        dg_fame.ShowHeader = true;
        dg_fame.DataSource = dt;
        dg_fame.DataBind();
        cs.Close();
        cs.Dispose();
    }

    protected void dg_fameDataBound(object sender, EventArgs e)
    {
        {
            dg_fame.HeaderRow.Cells[0].Text = "test";
            dg_fame.HeaderRow.Cells[1].Text = "test";
            dg_fame.HeaderRow.Cells[2].Text = "test";
        }
    }

0 个答案:

没有答案