妖怪:为什么使用SqlDataSource时,一段语句放在前,数据显示;一段语句放在后,数据不显示?
我的一个页面的Page_Load如下:
protected void Page_Load(object sender, EventArgs e)
{
string rid = "", manage = "";
//判断用户是否登录
if (Session["userid"].ToString() == "")
{
Response.Redirect("../Hint.aspx?HintText=请先登陆", false);
return;
}
if (!this.Page.IsPostBack)
{
//是否从AddRecQue.aspx而来
ViewState["sourcepage"] = Session["sourcepage"].ToString();
Session["sourcepage"] = "";
//显示数据
LblUserName.Text = "当前用户:" + Session["username"].ToString();
//特殊的一段
manage = Request.QueryString["manage"];
if (manage != "1") manage = "0";
if (manage == "1")
Panel_Read.Visible = false;
else
Panel_Manage.Visible = false;
rid = Request.QueryString["rid"];
SqlDataSource1.SelectParameters["DocID"].DefaultValue = rid;
SqlDataSource2.SelectParameters["DocID"].DefaultValue = rid;
SqlDataSource2.SelectParameters["manage"].DefaultValue = manage;
if (ViewState["sourcepage"].ToString() != "")
SqlDataSource2.SelectParameters["isadd"].DefaultValue="0";
else
SqlDataSource2.SelectParameters["isadd"].DefaultValue="1";
SqlDataSource2.SelectParameters["userid"].DefaultValue = Session["userid"].ToString();
SqlDataSource3.SelectParameters["DocID"].DefaultValue = rid;
}
}
如果把其中的一段话放在最后,和SqlDataSource2、SqlDataSource3相连的datalist数据就不显示,但是和SqlDataSource1相连的gridview没有影响,一直显示。
protected void Page_Load(object sender, EventArgs e)
{
string rid = "", manage = "";
//判断用户是否登录
if (Session["userid"].ToString() == "")
{
Response.Redirect("../Hint.aspx?HintText=请先登陆", false);
return;
}
if (!this.Page.IsPostBack)
{
//是否从AddRecQue.aspx而来
ViewState["sourcepage"] = Session["sourcepage"].ToString();
Session["sourcepage"] = "";
//显示数据
LblUserName.Text = "当前用户:" + Session["username"].ToString();
rid = Request.QueryString["rid"];
SqlDataSource1.SelectParameters["DocID"].DefaultValue = rid;
SqlDataSource2.SelectParameters["DocID"].DefaultValue = rid;
SqlDataSource2.SelectParameters["manage"].DefaultValue = manage;
if (ViewState["sourcepage"].ToStrin