我使用这样的数据表填充gridview:
protected void btnEdit_Click(object sender, EventArgs e)
{
FillGrid();
}
public void FillGrid() {
foreach (ListItem item in lblType.Items)
{
if (item.Selected)
{
DataTable data = AppDataAccess.GetData(item.Value, txtid.Value);
GridView1.DataSource = data;
GridView1.DataBind();
}
}
}
无法检索如下所示的更新数据,因为数据来自多个数据库表。
protected void grdContact_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int index = GridView1.EditIndex;
GridViewRow row = GridView1.Rows[index];
TextBox t1 = row.FindControl("TextBox1") as TextBox;
TextBox t2 = row.FindControl("TextBox2") as TextBox;
string t3 = GridView1.DataKeys[e.RowIndex].Value.ToString();
lblRecord.Text = "Updated record " + t1.Text + "," + t2.Text + "Value From Bound Field" + t3;
}
有没有办法可以从Gridview行动态检索更新的数据? 提前谢谢。