protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if ((e.Row.RowState & DataControlRowState.Edit) != 0)
{
DropDownList dp1 = (DropDownList)(e.Row.FindControl("DropDownList1"));
}
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
DropDownList dp1 =
(DropDownList)GridView1.Rows[GridView1.EditIndex].FindControl("DropDownList1");
this.SqlDataSource1.UpdateParameters["编号"].DefaultValue = dp1.SelectedValue;
}
if ((e.Row.RowState & DataControlRowState.Edit) != 0)
{
DropDownList dp1 = (DropDownList)(e.Row.FindControl("DropDownList1"));
}
如果当前的行的状态出于非编辑状态,在当前行中寻找一个名为DropDownList1的下拉框。
DropDownList dp1 =
(DropDownList)GridView1.Rows[GridView1.EditIndex].FindControl("DropDownList1");
this.SqlDataSource1.UpdateParameters["编号"].DefaultValue = dp1.SelectedValue;
当前行处于更新状态(在点击Update时候),获取当前编辑行的下拉框,然后获取选择的数据,赋值到SqlDataSource的UpdateParameters中。以便更新。
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息