ASP.NET2.0下含有DropDownList的GridView编辑、删除的完整例子!(8) string DB1_1 = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox1")).Text; //string DB1_2 = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("TextBox2")).Text; string DB1_2 = (((DropDownList))GridView1.Rows[e.RowIndex].FindControl("ddlXL")).SelectedItem.Text; //判断表单项是否有空并给出提示信息 if (DB1_1 == "" DB1_2 == "") { conn.Alert("请输入完整信息!", Page); return; } try { conn.BuilderEdit("select * from DB1 where DB1_1 ='" + ID + "'"); conn.dr["DB1_1"] = DB1_1; conn.dr["DB1_2"] = DB1_2; conn.BuilderEditClose(); } catch (OracleException err) { if (err.Code.ToString() == "1") conn.Alert("错误:已存在具有相同主键的记录", Page); else conn.Alert("错误:未能添加记录", Page); }
Response.Write("<script language='Javascript'>alert('数据已被保存!');</script>");