Hi I want to make dynamic check boxes(not a checkbox list) with xml but I am having trying to find tutorials on how to do this.
I also need them to explain almost everything in there code since I am new to C# and xml and asp.net.
Thanks
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Munir ShaikhRank #472 · 5.3K reputationPosted Aug 6, 2007, 9:04 PM EDT
Check this URL this might help you.
http://communityserver.org/forums/p/465795/500344.aspx
Regards,
>>Munnamax
aa10 reputationPosted Aug 6, 2007, 9:17 PM EDT
So I am using a database that will have say 10values letters and 10image urls in it. So I am going to make a check box for each one and a image box for each one.
I have managed to make the text boxes appear and the images but I want the user to choose what check boxes they want and then hit a button. When they hit the button it would go through all the checkboxes and see if they where selected(this is where I run into problems).
However I am doing all this code in the page_load and it seems that after it has finished loading those boxes that where made can't be access. So now I can't check which ones where selected.
So in my button I have
protected void Button1_Click(object sender, EventArgs e)
{
if (test.Checked == true)
{
ArrayList arrary = new ArrayList();
arrary.Add(test.ID);
Response.Write(test.ID + "checked" + "
");
}
}
So the line where I have test.checked, test being the checkbox object name does not work since it can't access it anymore
Here is my full code
1 using System; 2 using System.Data; 3 using System.Configuration; 4 using System.Collections; 5 using System.Web; 6 using System.Web.Security; 7 using System.Web.UI; 8 using System.Web.UI.WebControls; 9 using System.Web.UI.WebControls.WebParts; 10 using System.Web.UI.HtmlControls; 11 using System.Data.SqlClient; 12 13 public partial class Default4 : System.Web.UI.Page 14 { 15 16 protected void Page_Load(object sender, EventArgs e) 17 { 18 SqlConnection conn = new SqlConnection("Server=localhost\\SqlExpress;Database=Japanese;" + 19 "Integrated Security=True"); 20 SqlCommand comm = new SqlCommand("SELECT HiriganaID,letter,image FROM test", conn); 21 conn.Open(); 22 SqlDataReader reader = comm.ExecuteReader(); 23 while (reader.Read()) 24 { 25 CheckBox test = new CheckBox(); 26 27 test.ID = (string) reader["letter"]; 28 29 Image image = new Image(); 30 image.ImageUrl = (string)reader["image"]; 31 Panel1.Controls.Add(image); 32 Panel1.Controls.Add(new LiteralControl("<br />")); 33 Panel1.Controls.Add(new LiteralControl(" ")); 34 Panel1.Controls.Add(new LiteralControl(" ")); 35 Panel1.Controls.Add(new LiteralControl(" ")); 36 Panel1.Controls.Add(test); 37 Panel1.Controls.Add(new LiteralControl("<br />")); 38 } 39 reader.Close(); 40 conn.Close(); 41 } 42 protected void Button1_Click(object sender, EventArgs e) 43 { 44 45 if (test.Checked == true) 46 { 47 ArrayList arrary = new ArrayList(); 48 arrary.Add(test.ID); 49 Response.Write(test.ID + "checked" + "<br />"); 50 } 51 } 52 53 54 } 55 56 57