ASP.NET从入门到精通 第二版 新闻发布系统 新闻发布系统 P 499 页:
public partial class NewsAdd : System.Web.UI.Page
{
CommonClass CC = new CommonClass();
protected void Page_Load(object sender, EventArgs e)
{
switch (Convert.ToInt32(Request["id"].ToString()))
{
case 1:
this.labTitle.Text = "时政要闻";
break;
case 2:
this.labTitle.Text = "经济动向";
break;
case 3:
this.labTitle.Text = "世界军事";
break;
case 4:
this.labTitle.Text = "科学教育";
break;
case 5:
this.labTitle.Text = "法制道德";
break;
case 6:
this.labTitle.Text = "社会现象";
break;
case 7:
this.labTitle.Text = "体育世界";
break;
case 8:
this.labTitle.Text = "时尚娱乐";
break;
default:
this.labTitle.Text = "";
break;
}
}
---------这段代码中, switch (Convert.ToInt32(Request["id"].ToString())),id应该是取数据库中的新闻类别名;但vs提示对象没有实例化或取值为空;麻烦问下,应该怎样修改代码呢?还是先在数据库添加这些新闻类别字段?ps,有第二版的实例源程序吗?客服只提供了第四版的下载地址,谢谢!