|
发表于 2020-4-24 09:15:01
|
显示全部楼层
后台:
protected void Page_Load(object sender, EventArgs e)
{
System.Collections.Hashtable ht = new Hashtable();
ht.Add("AA", true);
ht.Add("BB", false);
ht.Add("CC", "2");
ht.Add("DD", "3");
ht.Add("EE", "3");
this.GridView1.DataSource = ht;
this.GridView1.DataBind();
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "detail")
{
int iIndex = Convert.ToInt32(e.CommandArgument);
GridViewRow row = this.GridView1.Rows[iIndex];
GridViewRow NewRow = new GridViewRow(iIndex + 1, iIndex, DataControlRowType.DataRow, DataControlRowState.Normal);
NewRow.Cells.Add(new TableCell());
NewRow.Cells[0].ColumnSpan = row.Cells.Count;
DataTable dt = new DataTable();
dt.Columns.Add("A", typeof(string));
dt.Columns.Add("B", typeof(string));
dt.Columns.Add("C", typeof(Int32));
DataRow r1 = dt.NewRow();
r1[0] = "软件工程";
r1[1] = "06-01-12";
r1[2] = 8000;
dt.Rows.Add(r1);
r1 = dt.NewRow();
r1[0] = "网站开发";
r1[1] = "06-11-10";
r1[2] = 12000;
dt.Rows.Add(r1);
this.rp1.DataSource = dt.DefaultView;
this.rp1.DataBind();
this.GridView1.Controls[0].Controls.AddAt(iIndex+2,NewRow);
NewRow.Cells[0].Controls.Add(this.rp1);
}
|
|