Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get Dynamic checkbox control id's by checked is true?
    primarykey
    data
    text
    <p>I am dynamically generating checkboxes, all this wrote in page_load</p> <p>My requirement is:</p> <p>if i check the checkboxes i want count of the number of checkboxes checked and radio buttons will appeared relative checked checkboxes.</p> <pre><code>CheckBox cb = (CheckBox)Page.FindControl("chk" + j); </code></pre> <p>even i checked the checkbox the cd shows checked = false</p> <p>below is the code:</p> <pre><code> string strfromdt = Session["leavefrm"].ToString(); DateTime startDate = Convert.ToDateTime(strfromdt); string strtodt = Session["leaveto"].ToString(); DateTime endDate = Convert.ToDateTime(strtodt); string strdays = Session["noofdays"].ToString(); float daysf = float.Parse(strdays); float days = (float)Math.Ceiling(daysf); CheckBox chk; Label lbl; RadioButton rd; days++; OleDbCommand cmd; DbConnection.Open(); cmd = new OleDbCommand("select HOL_DATE from IND_HOLIDAYS", DbConnection); OleDbDataAdapter da = new OleDbDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); for (int j = 1; j &lt;= days - 1; j++) { while(startDate &lt;= endDate) { for (int i = 0; i &lt;= dt.Rows.Count - 1; i++) { string strdate = dt.Rows[i]["HOL_DATE"].ToString(); DateTime date = Convert.ToDateTime(strdate); if (startDate == date) startDate = startDate.AddDays(1); } if ((startDate.DayOfWeek == DayOfWeek.Saturday) || ((startDate.DayOfWeek == DayOfWeek.Sunday))) { startDate = startDate.AddDays(1); continue; } break; } chk = new CheckBox(); chk.ID = j.ToString(); chk.AutoPostBack = true; // chk.Checked = true; lbl = new Label(); lbl.Text = startDate.ToString("dd/MM/yyyy"); lbl.ID = j.ToString(); PlaceHolder1.Controls.Add(lbl); PlaceHolder1.Controls.Add(chk); PlaceHolder1.Controls.Add(new RadioButton { }); PlaceHolder1.Controls.Add(new LiteralControl("&lt;BR&gt;")); startDate = startDate.AddDays(1); CheckBox cb = (CheckBox)Page.FindControl("chk" + j); //chk.Checked = CheckBox1Checked; //chk.oncheckedchanged += CheckBox1OnChecked; int chkcount = 0; if (chk.Checked) { chkcount++; } int chkcount1 = chkcount; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload