分类:
2009-11-23 15:11:01
第二部分
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
HiddenField1.Value = Session["UserName"].ToString();
Label1.Text = HiddenField1.Value;
getdata();
}
}
protected void getdata()
{
myco = new MySqlConnection(strconn);
myco.Open();
string IDUSE_ = HiddenField1.Value;
string sql = "select * from logtable where IDUSE= '" + IDUSE_ + "'";
MySqlDataAdapter myAdapter = new MySqlDataAdapter(sql, myco);
DataSet ds = new DataSet();
myAdapter.Fill(ds);
DataList1.DataSource = ds.Tables[0];
DataList1.DataKeyField = "IDRizhi";
DataList1.DataBind();
ds.Dispose();
myAdapter.Dispose();
myco.Close();
}
protected void DataList1_ItemDataBound(object source, DataListItemEventArgs e)
{
((LinkButton)e.Item.Controls[0].FindControl("LinkButton1")).Attributes.Add("onclick", "return confirm('您确定要删除吗?')");
}
protected void DataList1_DeleteCommand(object source, DataListCommandEventArgs e)
{
int IDRizhi_ = Int32.Parse(DataList1.DataKeys[e.Item.ItemIndex].ToString());
myco = new MySqlConnection(strconn);
myco.Open();
string sql = "delete from logtable where IDRizhi=" + IDRizhi_ + "";
mycomm = new MySqlCommand(sql, myco);
dr = mycomm.ExecuteReader();
mycomm.Dispose();
Label4.Text = "已删除";
getdata();
}
限制标题长度,设置MaxLength为50
条件判断
if (Title == "")
{
TextBox1.Focus();
Label3.Visible = true;
Label3.Text = "标题不能为空";
}
else
{
要执行的操作
}
查询日志要做的操作
按日期查,按标题查
UserLogQue.aspx
按标题查找
模糊查询
SELECT * FROM logtable l where Title like '%页面%';