string classid = Request.QueryString["classid"].ToString(); 未将对象引用设置到对象的实例。为撒?
上个页面同样这样定义的就行的,换到这个页面就不行了stringnews_dns=Convert.ToString(ConfigurationManager.Connect...
上个页面同样这样定义的 就行的,换到这个页面就不行了
string news_dns = Convert.ToString(ConfigurationManager.ConnectionStrings["ConnectionString"]);
myConn = new SqlConnection(news_dns);
string classid = Request.QueryString["classid"].ToString();
string sql_string = "select class_name from class where class_id=" + classid;
SqlDataAdapter myAdap1 = new SqlDataAdapter(sql_string, myConn);
DataSet myds1 = new DataSet();
myAdap1.Fill(myds1, "类别");
Label1.Text = myds1.Tables[0].Rows[0][0].ToString();
sql_string = "select news_id,news_title,news_datetime,news_hit_num,(newsuser.user_name) as author from news,newsuser where news.news_author=newsuser.user_id and news_class=" + classid;
SqlDataAdapter myAdap2 = new SqlDataAdapter(sql_string, myConn);
DataSet myds2 = new DataSet();
myAdap2.Fill(myds2, "类别");
GridView1.DataSource = new DataView(myds2.Tables[0]);
GridView1.DataBind();
asp的 gridview控件中的datanavigateurlformatstring格式是怎么样的,我感觉我写的不对 我的是这样的 news/新闻中心.aspx?classid={0} 展开
string news_dns = Convert.ToString(ConfigurationManager.ConnectionStrings["ConnectionString"]);
myConn = new SqlConnection(news_dns);
string classid = Request.QueryString["classid"].ToString();
string sql_string = "select class_name from class where class_id=" + classid;
SqlDataAdapter myAdap1 = new SqlDataAdapter(sql_string, myConn);
DataSet myds1 = new DataSet();
myAdap1.Fill(myds1, "类别");
Label1.Text = myds1.Tables[0].Rows[0][0].ToString();
sql_string = "select news_id,news_title,news_datetime,news_hit_num,(newsuser.user_name) as author from news,newsuser where news.news_author=newsuser.user_id and news_class=" + classid;
SqlDataAdapter myAdap2 = new SqlDataAdapter(sql_string, myConn);
DataSet myds2 = new DataSet();
myAdap2.Fill(myds2, "类别");
GridView1.DataSource = new DataView(myds2.Tables[0]);
GridView1.DataBind();
asp的 gridview控件中的datanavigateurlformatstring格式是怎么样的,我感觉我写的不对 我的是这样的 news/新闻中心.aspx?classid={0} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询