Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string query = Request.Params["q"].ToString();

        DataSource2.SelectCommand = "select Id,Gen_stire from Categorie where Id=" + query;
        DataSource2.DataBind();

        if (!Page.IsPostBack && Request.Params["q"] != null && Request.Params["p"] == null)
        {
            DataSource1.SelectCommand = "select Id,Gen_stire,Titlu,Descriere,Autor,Data,Imagine,Catchphrase from Stiri where Gen_stire=" + query;
            DataSource1.DataBind();
        }

        if (!Page.IsPostBack && Request.Params["q"] != null && Request.Params["p"] != null)
        {
            string query1 = Request.Params["p"].ToString();


            if (query1 != "Data1")
            {
                DataSource1.SelectCommand = "select Id, Titlu, Descriere, Autor, Data, Imagine, Catchphrase from Stiri where Gen_stire=" + query + " order by " + query1;
                DataSource1.DataBind();
            }
            else
            {
                DataSource1.SelectCommand = "select Id, Titlu, Descriere, Autor, Data, Imagine, Catchphrase from Stiri where Gen_stire=" + query + " order by Data desc";
                DataSource1.DataBind();
            }
        }
    }
    public void BindData()
    {
        var username = HttpContext.Current.User.Identity.Name;

        var user = _db.t_Users.SingleOrDefault(s => s.Username == username);

        if (user != null)
        {
            if (user.Role.ToLower() == "staff")
            {
                ListView1.DataSource = DataSource1;
                DataSource1.DataBind();
            }
            if (user.Role.ToLower() == "consumer")
            {
                ListView1.DataSource = DataSource2;
                DataSource2.DataBind();
            }
        }

        ListView1.DataBind();
    }
Esempio n. 3
0
 protected void Timer1_Tick(object sender, EventArgs e)
 {
     DataSource1.DataBind();
     ListView1.DataBind();
 }