private void dlstCategories_EditCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
{
if ( Context.User.Identity.Name.ToLower() != "admin")
{
Response.Redirect("/Wish/Modules/User/Login.aspx?ShowError=true",true);
}
SqlConnection cn = new SqlConnection (System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand cmd = new SqlCommand ("sp_Forums_GetCategoryDetails",cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@CategoryID",SqlDbType.Int,4).Value = (int)dlstCategories.DataKeys[e.Item.ItemIndex];
cn.Open();
SqlDataReader dr = cmd.ExecuteReader();
if ( dr.Read())
{
txtCategoryName.Text = dr["CategoryName"].ToString();
txtCategoryImageUrl.Text = dr["CategoryImageUrl"].ToString();
txtCategoryPosition.Text = dr["CategoryPosition"].ToString();
txtCategoryIDCurr.Text = dr["CategoryIDCurr"].ToString();
lblCategoryHeader.Text= "编辑版区";
}
cn.Close();
pnlCategory.Visible = true;
this.BindList();
}
运行到cn.open();出现ConnectionString 属性尚未初始化。