public partial class _Default : System.Web.UI.Page
{ public void Show_Works()
{
if (Request["username"] == null)
{
Response.Write("<script LANGUAGE='javascript'>alert('您的用户名有误!');window.close();</script>");
}
else
{
string username = Request["username"].ToString().Trim();
Session["username"] = username; SqlConnection con = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["carConnectionString"].ToString());
{
//判断power看是否有权限使用,或者username是否正确
string cmd1 = "select * from powers where username='" + username + "' and power=1";
SqlDataAdapter da = new SqlDataAdapter(cmd1, con);
DataSet ds = new DataSet();//创建数据集
da.Fill(ds);//填充数据集
DataTable dt = ds.Tables[0];
if (dt.Rows.Count == 0)
{
Response.Write("<script LANGUAGE='javascript'>alert('您没有权限使用该功能!');window.close();</script>");
} //查找和显示今天的工作
cmd1 = "select * from works where username='" + username + "' and wdate='" + Session["times"].ToString() + "'";
da = new SqlDataAdapter(cmd1, con);
ds = new DataSet();//创建数据集
da.Fill(ds);//填充数据集
dt = ds.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++)
{
Label lb = new Label();
lb.Text = dt.Rows[i]["wcontain"].ToString().Trim();
lb.CssClass = "lbs";
lb.Attributes.Add("ondblclick", "justtest()");
lb.ID = dt.Rows[i]["wid"].ToString().Trim();
this.Panel1.Controls.Add(lb); } }
}
} protected void Page_Load(object sender, EventArgs e)
{
Session["times"] = DateTime.Now.Date.ToString(); Show_Works(); } protected void Next_Click(object sender, EventArgs e)
{
this.Panel1.Controls.Clear();
Session["times"] = DateTime.Parse(Session["times"].ToString()).AddDays(1).ToString();
Show_Works();
}
}============================================================================================
只要看Next_Click(object sender, EventArgs e)方法即可,这是单击按钮的时候执行的事件。希望按一次,则Session["times"]自动加一!现在是点击第一次的时候Session["times"]成功加一了,但再点击的时候就没有任何改变了,请问这是为什么啊?
{ public void Show_Works()
{
if (Request["username"] == null)
{
Response.Write("<script LANGUAGE='javascript'>alert('您的用户名有误!');window.close();</script>");
}
else
{
string username = Request["username"].ToString().Trim();
Session["username"] = username; SqlConnection con = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["carConnectionString"].ToString());
{
//判断power看是否有权限使用,或者username是否正确
string cmd1 = "select * from powers where username='" + username + "' and power=1";
SqlDataAdapter da = new SqlDataAdapter(cmd1, con);
DataSet ds = new DataSet();//创建数据集
da.Fill(ds);//填充数据集
DataTable dt = ds.Tables[0];
if (dt.Rows.Count == 0)
{
Response.Write("<script LANGUAGE='javascript'>alert('您没有权限使用该功能!');window.close();</script>");
} //查找和显示今天的工作
cmd1 = "select * from works where username='" + username + "' and wdate='" + Session["times"].ToString() + "'";
da = new SqlDataAdapter(cmd1, con);
ds = new DataSet();//创建数据集
da.Fill(ds);//填充数据集
dt = ds.Tables[0];
for (int i = 0; i < dt.Rows.Count; i++)
{
Label lb = new Label();
lb.Text = dt.Rows[i]["wcontain"].ToString().Trim();
lb.CssClass = "lbs";
lb.Attributes.Add("ondblclick", "justtest()");
lb.ID = dt.Rows[i]["wid"].ToString().Trim();
this.Panel1.Controls.Add(lb); } }
}
} protected void Page_Load(object sender, EventArgs e)
{
Session["times"] = DateTime.Now.Date.ToString(); Show_Works(); } protected void Next_Click(object sender, EventArgs e)
{
this.Panel1.Controls.Clear();
Session["times"] = DateTime.Parse(Session["times"].ToString()).AddDays(1).ToString();
Show_Works();
}
}============================================================================================
只要看Next_Click(object sender, EventArgs e)方法即可,这是单击按钮的时候执行的事件。希望按一次,则Session["times"]自动加一!现在是点击第一次的时候Session["times"]成功加一了,但再点击的时候就没有任何改变了,请问这是为什么啊?
解决方案 »
- Object reference not set to an instance of an object
- 用ASP.net 调用 matlab 的问题
- treeview问题
- TreeView's TreeView_HoverNode error
- 在DataGrid里添加一模板列,在模板列放置CheckBox问题 在线等!!!
- 用类库、还是用组件。
- 一个点击了aspx中的一个runat="server" 的按钮后的页面刷新问题
- DropDownList绑定数据源后,如何显示“请选择”?
- 这是因为什么出错的????
- 如何去掉web页面上显示的图片的属性中的全路经!
- 有关对mysql数据库用excel进行数据导入
- 重写textbox,为什么不能赋值
[code=C#]protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Session["times"] = DateTime.Now.Date.ToString();
}
}
{
Session["times"] = DateTime.Now.Date.ToString();
}
断点,单步
{
首次在这里执行 回调的不会执行
}
可以这样修改
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
Session["times"] = DateTime.Now.Date.ToString();
}
Show_Works(); }