protected void gd_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox txtAuthor;
TextBox txtBook;
dt = new DataTable();
dt=(DataTable)ViewState["dt"];
GridViewRow gdr = gd.Rows[e.RowIndex];
if (gdr != null)
{
txtAuthor = (TextBox)gd.Rows[e.RowIndex].FindControl("txtAuthor1");
txtBook = (TextBox)gd.Rows[e.RowIndex].FindControl("txtBook1");
dt = (DataTable)ViewState["dt"];
string txtAuthorName;
string txtBookName;
if (txtAuthor != null && txtBook!=null)
{
txtAuthorName = txtAuthor.Text;
txtBookName = txtBook.Text;
int i=0;
dt = (DataTable)Session["dt"];
for (; i < gd.Rows.Count; i++)
{
if (e.RowIndex == i)
{
dt.Rows[i][0] = txtAuthor.Text;
dt.Rows[i][1] = txtBook.Text;
ViewState["dt"] = dt;
gd.DataSource = dt;
gd.DataBind();
}
}
}
}
dt = (DataTable)ViewState["dt"];
gd.DataSource = dt;
gd.DataBind();
}
質問する
620 次