ใช้ CheckBoxList
มีค่าที่เก็บในตารางดังนี้ 1. การเงิน
2. ที่พัก
3. อุปกรณ์การศึกษา
4. เครื่องแต่งกาย
เราเลือกติ๊กข้อ 2 กับ 3 แต่ค่าที่เก็บลง database จะลงแค่ค่าแรกค่ะ ทำยังไงให้เก็บที่ถูกเลือกทั้งข้อ 2 และ 3 ได้ค่ะ ดังรูป(ใช้ SqlDatasource)



โค้ตที่ Insert ลง Database
string connString = @"Data Source=.\SQLEXPRESS;Initial Catalog=ScholarShipDb;Integrated Security=True"; SqlConnection ScholarShipConnection = new SqlConnection(connString); ScholarShipConnection.ConnectionString = connString; ScholarShipConnection.Open(); StringBuilder stb = new StringBuilder(); stb.Append("Insert into studentApply (Stu_ID,FirstName,LastName,ID_Card,Birthday,Age,Faculty,Major,Class,GPA,Address1,Soi,Road,Tumbon,Ampur,City,PostCode,Name_Father,Name_Mother,Income_Father,Income_Mother,Extraction,Nationality,Age_Father,Parentalive_Father,Occupation_Father,WorkPlace_Father,Tel_Father,Age_Mother,Parentalive_Mother,Occupation_Mother,WorkPlace_Mother,Tel_Mother,Area_Agriculture,Number_Area,Income_Year,Relation_Family,Relatives,Study,Earn,Family,Sex1,Name1,Level1,Occupation1,WorkPlace1,Income1,Sex2,Name2,Level2,Occupation2,WorkPlace2,Income2,Sex3,Name3,Level3,Occupation3,WorkPlace3,Income3,Sex4,Name4,Level4,Occupation4,WorkPlace4,Income4,Sex5,Name5,Level5,Occupation5,WorkPlace5,Income5,Expenses,Sponser_Name,About_Stu,Occupation_Sponser,Income_Sponser,Accessories_Support,Name_Scho1,Name_Scho2,Name_Scho3,Name_Scho4,Name_Scho5,Year1,Year2,Year3,Year4,Year5,Scho_Bath1,Scho_Bath2,Scho_Bath3,Scho_Bath4,Scho_Bath5,Activity,Activity1,Job,Job1,Doc_Composition,Image_Doc) values (@Stu_ID,@FirstName,@LastName,@ID_Card,@Birthday,@Age,@Faculty,@Major,@Class,@GPA,@Address1,@Soi,@Road,@Tumbon,@Ampur,@City,@PostCode,@Name_Father,@Name_Mother,@Income_Father,@Income_Mother,@Extraction,@Nationality,@Age_Father,@Parentalive_Father,@Occupation_Father,@WorkPlace_Father,@Tel_Father,@Age_Mother,@Parentalive_Mother,@Occupation_Mother,@WorkPlace_Mother,@Tel_Mother,@Area_Agriculture,@Number_Area,@Income_Year,@Relation_Family,@Relatives,@Study,@Earn,@Family,@Sex1,@Name1,@Level1,@Occupation1,@WorkPlace1,@Income1,@Sex2,@Name2,@Level2,@Occupation2,@WorkPlace2,@Income2,@Sex3,@Name3,@Level3,@Occupation3,@WorkPlace3,@Income3,@Sex4,@Name4,@Level4,@Occupation4,@WorkPlace4,@Income4,@Sex5,@Name5,@Level5,@Occupation5,@WorkPlace5,@Income5,@Expenses,@Sponser_Name,@About_Stu,@Occupation_Sponser,@Income_Sponser,@Accessories_Support,@Name_Scho1,@Name_Scho2,@Name_Scho3,@Name_Scho4,@Name_Scho5,@Year1,@Year2,@Year3,@Year4,@Year5,@Scho_Bath1,@Scho_Bath2,@Scho_Bath3,@Scho_Bath4,@Scho_Bath5,@Activity,@Activity1,@Job,@Job1,@Doc_Composition,@Image_Doc) ");
SqlCommand cmd = ScholarShipConnection.CreateCommand();
cmd.Parameters.Add("@Accessories_Support", SqlDbType.NVarChar).Value = Accessories_Support.Text;
รบกวนทีค่ะ ขอบคุณค่ะ