using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Configuration; using System.Data; using System.Data.SqlClient; public partial class Default7 : System.Web.UI.Page { private SqlConnection CN() { SqlConnection con = new SqlConnection(); con.ConnectionString = ConfigurationManager.ConnectionStrings["aaa"].ToString(); con.Open(); return con; } DataSet ds; string sql; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { sql = "select*from tblproduct"; SqlCommand cm = new SqlCommand(sql, CN()); ds = new DataSet(); SqlDataAdapter da = new SqlDataAdapter(sql, CN()); da.Fill(ds, "product"); Label1.Text = Session["a"].ToString(); Label2.Text = null; } } protected void Button1_Click(object sender, EventArgs e) { double price=0; double x = Convert.ToDouble(Label1.Text); //ติดErrorตรงนี้ครับ if (RadioButtonList1.SelectedIndex == 0) price = x; else price = x * 0.10; Label2.Text = (price.ToString("n2" + " บาท")); } }
Quote:Label1.Text
double x = Convert.ToDouble(Session["SessionName"]);
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง