【发布时间】:2014-03-11 06:04:32
【问题描述】:
我想在不使用普通更新命令的情况下更新网格视图时运行一些方法。不过,我相信我可以使用 RowUpdating 来做到这一点。
protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int selectedRowIndex = e.RowIndex;
TextBox txtID = (TextBox)GridView2.Rows[e.RowIndex].FindControl("TextBox13");
TextBox txtDate1 = (TextBox)GridView2.Rows[e.RowIndex].FindControl("txtDate1");
TextBox txtDate2 = (TextBox)GridView2.Rows[e.RowIndex].FindControl("txtDate2");
Label duration = (Label)GridView2.Rows[e.RowIndex].FindControl("Label13");
Label diff = (Label)GridView2.Rows[e.RowIndex].FindControl("Label14");
Label remainder = (Label)GridView2.Rows[e.RowIndex].FindControl("Label15");
Label expiry = (Label)GridView2.Rows[e.RowIndex].FindControl("Label17");
DropDownList ddlName = (DropDownList)GridView2.Rows[e.RowIndex].FindControl("ddlName");
DropDownList ddlType = (DropDownList)GridView2.Rows[e.RowIndex].FindControl("ddlType");
DropDownList ddlLocation = (DropDownList)GridView2.Rows[e.RowIndex].FindControl("ddlLocation");
DropDownList ddlFee = (DropDownList)GridView2.Rows[e.RowIndex].FindControl("ddlFee");
//dc.updateArchive(Variables goes here);
GridView2.DataBind();
GridView2.EditIndex = -1; }
搞砸之后,我能够从所选行(我单击“编辑”的行)中读取值,但这里发生的情况是,每一行都使用我在“编辑”行中输入的相同值进行更新模式(选择?)。
我需要获取正在编辑的行的数据键。我怎样才能做到这一点?
【问题讨论】:
标签: c# asp.net sql-server linq gridview