public void bindGridView1() { try { Playlist pl = new Playlist(); DataSet ds = pl.LoadAllMP(); bool check = IsEmpty(ds); if (!check) { GridView1.DataSource = ds; GridView1.DataBind(); Label1.Text = ""; ViewStat["flag"] = "true"; } else { Label1.Text = "No data found!"; } } catch (Exception e) { Label1.Text = "The Server is down! Try again later!"; } }
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { Playlist pl = new Playlist(); DataSet ds; if (Page.IsPostBack) { // Retrieve and display the property value. flag = (string)ViewState["flag"]; } if (flag == "true") { ds = pl.LoadAllMP(); } else { ds = pl.LoadByLocationMP(txbLocation.Text); } int currentPage = GridView1.PageIndex; int pos = currentPage * 10; DataRow dr = ds.Tables[0].Rows[GridView1.SelectedIndex + pos]; int index = (int)dr["id_playlist"]; Music mus = new Music(); DataSet ds2 = mus.LoadById_playlist(index); GridView2.DataSource = ds2; GridView2.DataBind(); }