【发布时间】:2016-05-30 10:49:55
【问题描述】:
我正在尝试使用链接按钮从转发器中删除子类别。目前,主要类别已删除,但我无法删除子类别。请帮帮我...
private void BindRepeater()
{
DataTable dtCategory = system.GetDataTable("Select * from TBLCATEGORIES where SubCategoryID="+CategoryID);
if (dtCategory.Rows.Count > 0)
{
rpCategory.DataSource = dtCategory;
rpCategory.DataBind();
}
}
protected void OnDelete(object sender, EventArgs e)
{
//Find the reference of the Repeater Item.
RepeaterItem item = (sender as LinkButton).Parent as RepeaterItem;
string constr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
SqlCommand cmd = new SqlCommand("Delete from TBLCATEGORIES where SubCategoryID="+CategoryID);
{
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
DeleteMsg.Visible = true;
}
}
this.BindRepeater();
}
【问题讨论】:
-
只有删除的行是Repeater中的唯一行时才会出现问题,还是Repeater中有几行时也会出现问题?
标签: c# sql asp.net sql-server-2008