Example #1
0
    protected void DataBindUsers()
    {
        System.Data.Objects.ObjectParameter total = new System.Data.Objects.ObjectParameter("total", typeof(int));
        string keywords = null;

        if (txtSearch.Text.Trim() != string.Empty && txtSearch.Text.Trim().ToLower() != "Търсене")
        {
            keywords = txtSearch.Text;
        }

        GridViewExistingUsers.DataSource = entities.GetAllUsers(keywords, SortingColumn, SortingDirection == "sortingasc" ? "ASC" : "DESC", base.StartRow, base.PageSize, total);
        GridViewExistingUsers.DataBind();

        base.TotalRows     = (int)total.Value;
        lblTotalUsers.Text = "Брой: " + total.Value.ToString();
    }
    protected void DataBindUsers()
    {
        System.Data.Objects.ObjectParameter total = new System.Data.Objects.ObjectParameter("total", typeof(int));

        var result = entities.GetAllUsers(null, "FirstName", "ASC", 1, 100000, total);

        DataTable allUsers = new DataTable();

        allUsers.Columns.Add("Name", typeof(string));
        allUsers.Columns.Add("currentUserName", typeof(string));
        foreach (var user in result)
        {
            string name            = user.FirstName + " " + user.LastName;
            string currentUserName = user.currentUserName.ToString();
            allUsers.Rows.Add(name, currentUserName);
        }

        ddlUsers.DataSource     = allUsers;
        ddlUsers.DataTextField  = "Name";
        ddlUsers.DataValueField = "currentUserName";
        ddlUsers.DataBind();
    }