日期:2014-05-17 浏览次数:20435 次
protected void Page_Load(object sender, EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter("select distinct Department from jz", connn);
DataTable dt = new DataTable();
da.Fill(dt);
Button[] Mybuttoe = new Button[dt.Rows.Count];
for (int i = 0; i < Mybuttoe.Length; i++)
{
Mybuttoe[i] = new Button();
buttoe.ID = "Mybuttoe" + i;
Mybuttoe[i].Text = dt.Rows[i][0].ToString().Trim();
Mybuttoe[i].Style.Add("border", "1px solid #50657A");
Mybuttoe[i].Style.Add("background-color", "#5C758D");
Mybuttoe[i].Style.Add("height", "30px");
Mybuttoe[i].Style.Add("color", "#FFFFFF");
Mybuttoe[i].Style.Add("width", "81px");
Mybuttoe[i].Style.Add("cursor", "pointer");
Mybuttoe[i].Style.Add("font-size", "16px");
Mybuttoe[i].Style.Add("margin-left", "3px");
Mybuttoe[i].Click += new System.EventHandler(buttoe_Click);
fi.Controls.Add(Mybuttoe[i]);
}
}
protected void buttoe_Click(object sender, EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter("select jz.*,kc.Quantity from jz,kc where jz.KCID=kc.ID", connn);
da.Fill(ds, "jz");
GridView2.DataSource = ds.Tables[0];
GridView2.DataBind();
ds.Clear();
((Button)sender).Style.Add("color", "#FFFF00");
}