private void UpdateGridView()
        {
            SqlConnection conn = new SqlConnection(@"data source = .\SQLEXPRESS; integrated security = true; database = Pokemons");

            string sqlsel = "SELECT * FROM Pokemons";

            try
            {
                da = new SqlDataAdapter();
                da.SelectCommand = new SqlCommand(sqlsel, conn);

                ds = new DataSet();
                da.Fill(ds, "MyPokemons");
                dt = ds.Tables["MyPokemons"];

                GridViewUpdate.DataSource = dt;
                GridViewUpdate.DataBind();
            }
            catch (Exception ex)
            {
                LabelMessageUpdate.Text = ex.Message;
            }
            finally
            {
                conn.Close();
            }
        }
Exemple #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["user"] != null)
         {
             User us = (User)Session["user"];
             if (us.RoleID == 1)
             {
                 GridViewUpdate.DataSource = UpdateProductTypeController.getAllProductType();
                 GridViewUpdate.DataBind();
             }
             else
             {
                 Response.Redirect("Home.aspx");
             }
         }
         else
         {
             Response.Redirect("Home.aspx");
         }
     }
 }