예제 #1
0
        protected void findrend_Click(object sender, EventArgs e)
        {
            con.Open();
            string        sqladmin    = "SELECT * FROM book WHERE BookID = '" + BookIDrend.Text + "' ";
            SqlCommand    cmdAdmin    = new SqlCommand(sqladmin, con);
            SqlDataReader readerAdmin = cmdAdmin.ExecuteReader();

            readerAdmin.Read();
            if (readerAdmin.HasRows)
            {
                //ใส่ข้อมูลหนังสือในตาราง
                //Label1.Text = readerAdmin[1].ToString();
                if (Session["dtInSession"] != null)
                {
                    dt1 = (DataTable)Session["dtInSession"]; //Getting datatable from session
                }
                //Int32 total = Convert.ToInt32(txt_quantity.Text) * Convert.ToInt32(txt_price.Text);
                DataRow dr = dt1.NewRow();
                dr["Customer"] = user;
                dr["BookID"]   = readerAdmin[0].ToString();
                dr["NameBook"] = readerAdmin[1].ToString();
                dr["price"]    = readerAdmin[2].ToString();
                // dr["totalPrice"] = GridViewrend.Rows[0].Cells[3].Text;
                dt1.Rows.Add(dr);

                Session["dtInSession"]  = dt1;    //Saving Datatable To Session
                GridViewrend.DataSource = dt1;
                GridViewrend.DataBind();
            }

            lblShowPrice.Text = Total;
            readerAdmin.Close();
            con.Close();
        }
예제 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     findUser();
     if (!IsPostBack)
     {
         gridVIEWData();
         GridViewrend.DataSource = dt1;
         GridViewrend.DataBind();
     }
 }