Ejemplo n.º 1
0
        private void getDataToGv()
        {
            string    jsonText = CrazyKTVWCF.ViewSong(0, 1000); // it will be very slow if more than 2000
            DataTable dt       = GlobalFunctions.JsontoDataTable(jsonText);

            DataView dv = new DataView(dt);

            //dv.Sort = "Song_Singer asc, Song_SongName asc, Song_Id asc";

            GridView1.DataSource = dv;
            GridView1.DataBind();
        }
Ejemplo n.º 2
0
        private void getDataToGv()
        {
            string    jsonText = CrazyKTVWCF.ViewSong(0, GuiGlobal.QuerySongRows);
            DataTable dt       = GlobalFunctions.JsontoDataTable(jsonText);

            int CurPageSize = Convert.ToInt32(((HiddenField)this.Parent.FindControl("PlayListGridViewPageSize")).Value);

            if (CurPageSize < 1)
            {
                CurPageSize = 1;
            }

            // Desktop / Tablet Mode
            if (((HiddenField)this.Parent.FindControl("BootstrapResponsiveMode")).Value.Contains("Desktop"))
            {
                GridView1.PageSize = CurPageSize;

                if (dt.Rows.Count == 0)
                {
                    DataColumn col = new DataColumn("Song_Id");
                    dt.Columns.Add(col);
                    col = new DataColumn("Song_Lang");
                    dt.Columns.Add(col);
                    col = new DataColumn("Song_SongName");
                    dt.Columns.Add(col);
                    col = new DataColumn("Song_Singer");
                    dt.Columns.Add(col);
                }

                if (dt.Rows.Count > CurPageSize)
                {
                    if (dt.Rows.Count % CurPageSize > 0)
                    {
                        int NewRowCount = CurPageSize - (dt.Rows.Count % CurPageSize);
                        for (int i = 0; i < NewRowCount; i++)
                        {
                            DataRow row = dt.NewRow();
                            row["Song_Lang"] = " ";
                            dt.Rows.Add(row);
                        }
                    }

                    GridView1.AllowPaging = true;
                    GridView1.ShowFooter  = false;
                }
                else
                {
                    int NewRowCount = CurPageSize - dt.Rows.Count;
                    for (int i = 0; i < NewRowCount; i++)
                    {
                        DataRow row = dt.NewRow();
                        row["Song_Lang"] = " ";
                        dt.Rows.Add(row);
                    }
                    GridView1.ShowFooter = true;
                }
            }
            else
            {
                GridView1.PageSize    = 1;
                GridView1.AllowPaging = false;
                GridView1.ShowFooter  = false;
            }

            DataView dv = new DataView(dt);

            //dv.Sort = "Song_Singer asc, Song_SongName asc, Song_Id asc";

            GridView1.DataSource = dv;
            GridView1.DataBind();

            if (((HiddenField)this.Parent.FindControl("BootstrapResponsiveMode")).Value.Contains("Desktop"))
            {
                if (dt.Rows.Count > CurPageSize)
                {
                    DropDownList ddlSelectPage = (DropDownList)GridView1.BottomPagerRow.FindControl("SelectPage_DropDownList");
                    for (int i = 0; i < GridView1.PageCount; i++)
                    {
                        ddlSelectPage.Items.Add(new ListItem((i + 1).ToString(), i.ToString()));
                    }
                    ddlSelectPage.SelectedIndex = GridView1.PageIndex;
                }
            }
        }