数据源不支持服务器端的数据分页
if(!this.IsPostBack){stringnewsTypeID=Request.QueryString["TypeID"].ToString();SqlCon...
if(!this.IsPostBack)
{
string newsTypeID = Request.QueryString["TypeID"].ToString();
SqlConnection con = DB.createConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select newsTypeName from newsType where newsTypeID='" + newsTypeID + "'",con);
this.Label1.Text = Convert.ToString(cmd.ExecuteScalar());
cmd.CommandText = "select * from newsTile where newsTypeID='" + newsTypeID + "'";
SqlDataReader sdr = cmd.ExecuteReader();
this.GridView1.DataSource = sdr;
this.GridView1.DataBind();
}
知道要用Dataset 不知道怎么改啊 展开
{
string newsTypeID = Request.QueryString["TypeID"].ToString();
SqlConnection con = DB.createConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select newsTypeName from newsType where newsTypeID='" + newsTypeID + "'",con);
this.Label1.Text = Convert.ToString(cmd.ExecuteScalar());
cmd.CommandText = "select * from newsTile where newsTypeID='" + newsTypeID + "'";
SqlDataReader sdr = cmd.ExecuteReader();
this.GridView1.DataSource = sdr;
this.GridView1.DataBind();
}
知道要用Dataset 不知道怎么改啊 展开
3个回答
展开全部
f(!this.IsPostBack)
{
string newsTypeID = Request.QueryString["TypeID"].ToString();
SqlConnection con = DB.createConnection();
con.Open();
string sqlstr= "select * from newsTile where newsTypeID='" + newsTypeID + "'";
SqlDataAdapter da = new SqlDataAdapter(sqlstr,con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
这样就行了啊,看清楚了啊,呵呵
{
string newsTypeID = Request.QueryString["TypeID"].ToString();
SqlConnection con = DB.createConnection();
con.Open();
string sqlstr= "select * from newsTile where newsTypeID='" + newsTypeID + "'";
SqlDataAdapter da = new SqlDataAdapter(sqlstr,con);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
这样就行了啊,看清楚了啊,呵呵
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
if(!this.IsPostBack)
{
string newsTypeID = Request.QueryString["TypeID"].ToString();
SqlConnection con = DB.createConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select newsTypeName from newsType where newsTypeID='" + newsTypeID + "'",con);
this.Label1.Text = Convert.ToString(cmd.ExecuteScalar());
cmd.CommandText = "select * from newsTile where newsTypeID='" + newsTypeID + "'";
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet(); da.Fill(ds);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
最后四排改成了用Dataset来进行,这样就可以用数据分页。
{
string newsTypeID = Request.QueryString["TypeID"].ToString();
SqlConnection con = DB.createConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select newsTypeName from newsType where newsTypeID='" + newsTypeID + "'",con);
this.Label1.Text = Convert.ToString(cmd.ExecuteScalar());
cmd.CommandText = "select * from newsTile where newsTypeID='" + newsTypeID + "'";
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet(); da.Fill(ds);
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
最后四排改成了用Dataset来进行,这样就可以用数据分页。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询