DataList里有控件TextBox和LinkButton,LinkButton的CommandName属性为deleteResponse,我想通过点击LinkButton后执行
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "deleteResponse")
{
string strconn = Convert.ToString(ConfigurationManager.AppSettings["edu"]);
SqlConnection cn = new SqlConnection(strconn);
cn.Open();
Label lblTime= e.Item.FindControl("lblTime") as Label;
string mysql = "delete from Response where ResponseTime='" + lblTime.Text.ToString() + "'";
SqlCommand cm = new SqlCommand(mysql, cn);
cm.ExecuteNonQuery();
cn.Close();
}
}获取不了TextBox的内容,请问应该怎样做??谢谢!!
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "deleteResponse")
{
string strconn = Convert.ToString(ConfigurationManager.AppSettings["edu"]);
SqlConnection cn = new SqlConnection(strconn);
cn.Open();
Label lblTime= e.Item.FindControl("lblTime") as Label;
string mysql = "delete from Response where ResponseTime='" + lblTime.Text.ToString() + "'";
SqlCommand cm = new SqlCommand(mysql, cn);
cm.ExecuteNonQuery();
cn.Close();
}
}获取不了TextBox的内容,请问应该怎样做??谢谢!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货