protected void sgvFile1_RowDataBound(object sender, GridViewRowEventArgs e) {
DropDownList ddlAM = ((DropDownList)e.Row.FindControl("ddlAM")); ddlAM.SelectedIndexChanged += new EventHandler(ddlAM_SelectedIndexChanged); ddlAM.SelectedIndex = -1; ddlAM.Items.FindByValue(labAM.Text).Selected = true; }
protected void ddlAM_SelectedIndexChanged(object sender, EventArgs e) { DropDownList ddlAM = (DropDownList)sender; string i = ddlAM.ID.Substring(ddlAM.ID.LastIndexOf("ddlAM") + 5, ddlAM.ID.Length - 5); bool flage = false; GridViewRow row = (GridViewRow)ddlAM.NamingContainer; Label labAMPersonID = (Label)row.FindControl("labAMPersonID" + i); try { UpdateKaoQin(labAMPersonID.Text, ddlAM.SelectedValue); } catch { ScriptManager.RegisterClientScriptBlock(UpdatePanel1, typeof(UpdatePanel), "result", "alert('修改失败!');", true); } }