根据2个DropDownList控件把textbox的值更新到SQL数据库,代码怎么写,谢谢
展开全部
你是要用DropDownList来触发一个更新事件吗?
如果是的,可以这样实现:
收件要给DropDownList加入DropDownList_SelectedIndexChanged事件,
protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
//在此方法中年获取另一个DropDownList和textbox的值
string remark = textbox.text.trim();
string flowconfig_ID = DropDownList.selectedItem.value;
//做对数据库的更新操作就可以了:
string FCARegConnString = System.Configuration.ConfigurationManager.AppSettings["FCARegConnString"];
try
{
SqlConnection conn = new SqlConnection(FCARegConnString);
conn.Open();
string insertSys = "update flowconfig_info set isreturn = 1,Modify_Date=GETDATE(),Remark='" + remark + "' where flowconfig_id='" + flowconfig_ID + "'";
SqlCommand sqcom = new SqlCommand(insertSys, conn);
int i = sqcom.ExecuteNonQuery();
sqcom.Connection.Close();
if (i > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception e)
{
return false;
}
}
如果是的,可以这样实现:
收件要给DropDownList加入DropDownList_SelectedIndexChanged事件,
protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
{
//在此方法中年获取另一个DropDownList和textbox的值
string remark = textbox.text.trim();
string flowconfig_ID = DropDownList.selectedItem.value;
//做对数据库的更新操作就可以了:
string FCARegConnString = System.Configuration.ConfigurationManager.AppSettings["FCARegConnString"];
try
{
SqlConnection conn = new SqlConnection(FCARegConnString);
conn.Open();
string insertSys = "update flowconfig_info set isreturn = 1,Modify_Date=GETDATE(),Remark='" + remark + "' where flowconfig_id='" + flowconfig_ID + "'";
SqlCommand sqcom = new SqlCommand(insertSys, conn);
int i = sqcom.ExecuteNonQuery();
sqcom.Connection.Close();
if (i > 0)
{
return true;
}
else
{
return false;
}
}
catch (Exception e)
{
return false;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询