Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string username = Request.Params["username"];

        SqlUserSource.SelectCommand = "SELECT * FROM [USER] WHERE username = '******'";
        SqlUserSource.DataBind();

        string userId = getuserId(username);

        SqlArticleSource.SelectCommand = "SELECT * FROM [ARTICLE] where user_id = " + userId + " ORDER BY date_created DESC";
        SqlArticleSource.DataBind();
    }
Exemplo n.º 2
0
    protected void Setup_Articles(object sender, EventArgs e)
    {
        string category_id = Request.Params["category_id"];
        string orderBy     = OrderByList.SelectedValue;
        string direction   = DirectionList.SelectedValue;

        SqlArticleSource.SelectCommand = "SELECT * FROM ARTICLE where category_id = " + category_id + " ORDER BY " + orderBy + " " + direction;
        //SqlArticleSource.SelectParameters.Add("category_id", category_id);
        SqlArticleSource.DataBind();

        foreach (RepeaterItem repeaterItem in RepeaterArticle.Items)
        {
            //Set local urls and score label if ext_url is null
            HyperLink hyperLink = (HyperLink)repeaterItem.FindControl("ArticleHyperLink");
            if (hyperLink.NavigateUrl == "")
            {
                HiddenField articleIdHiddenField = (HiddenField)repeaterItem.FindControl("ArticleIdHiddenField");
                string      articleId            = articleIdHiddenField.Value;
                hyperLink.NavigateUrl = "Article.aspx?id=" + articleId;

                //Set article score
                Label scoreLabel = (Label)repeaterItem.FindControl("ScoreLabel");
                scoreLabel.Text = getArticleScore(articleId) + " points";
            }
            else
            {
                Label scoreLabel = (Label)repeaterItem.FindControl("ScoreLabel");
                scoreLabel.Visible = false;
            }

            //Change user ID to username
            HyperLink userLabel = (HyperLink)repeaterItem.FindControl("UserLabel");
            string    userId    = userLabel.Text;
            string    username  = getUsername(userId);
            userLabel.Text        = username;
            userLabel.NavigateUrl = "User.aspx?username="******"ThumbnailHiddenField");
            if (thumbnailData.Value == "")
            {
                var thumbnail = repeaterItem.FindControl("ArticleImage");
                thumbnail.Visible = false;
            }
        }
    }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string category_id = Request.Params["category_id"];

            SqlCategorySource.SelectCommand = "SELECT * FROM CATEGORY where id = " + category_id;
            //SqlCategorySource.SelectParameters.Add("category_id", category_id);
            SqlCategorySource.DataBind();

            string orderBy   = OrderByList.SelectedValue;
            string direction = DirectionList.SelectedValue;

            SqlArticleSource.SelectCommand = "SELECT * FROM ARTICLE where category_id = " + category_id + " ORDER BY " + orderBy + " " + direction;
            //SqlArticleSource.SelectParameters.Add("category_id", category_id);
            SqlArticleSource.DataBind();
        }
    }