Mi codigo:
Código PHP:
protected void Page_Load(object sender, EventArgs e)
{
CrearDT();
//Page.Session["VarSession"] = dtabla;
GridView1.DataSource = dtabla;
GridView1.DataBind();
}
Código PHP:
public DataTable CrearDT()
{
dtabla.Columns.Add("Dosage", typeof(int));
dtabla.Columns.Add("Drug", typeof(string));
dtabla.Columns.Add("Patient", typeof(string));
dtabla.Columns.Add("Date", typeof(DateTime));
return dtabla;
}
Código PHP:
public DataTable AddInfo()
{
dtabla.Rows.Add(25, "Indocin", "David", DateTime.Now);
dtabla.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
dtabla.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
dtabla.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
dtabla.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
return dtabla;
}
Código PHP:
protected void Button1_Click(object sender, EventArgs e)
{
//Session.Add("VarSession", AddInfo());
AddInfo();
GridView1.DataSource = dtabla;
GridView1.DataBind();
}
Código PHP:
protected void Button2_Click(object sender, EventArgs e)
{
DataRow dRow = dtabla.NewRow();
dRow["Dosage"] = 102;
dRow["Drug"] = "xx";
dRow["Patient"] = "xxx";
dRow["Date"] = DateTime.Now;
dtabla.Rows.Add(dRow);
//Page.Session["VarSession"] = dtabla;
//Session.Add("VarSession",dtabla);
GridView1.DataSource = dtabla;
GridView1.DataBind();
}