How to find the control???

Results 1 to 2 of 2

Thread: How to find the control???

  1. #1
    Join Date
    Dec 1969

    Default How to find the control???

    I have created a placeholder and at runtime based on the Datatype id value passed from db I am displaying a checkbox or radiolist or textfield inside the placeholder control in a table control<BR>e.g.<BR>Placeholder <BR>Table<BR>ChecekBoxList<BR><BR>I want to get the selected value of the checkboxlist.<BR>I have the following code<BR>PlaceHolder p = (PlaceHolder)(r.FindControl("PlaceHolder1"));<BR> <BR> if (p.Controls[0].ID == "TmpTable")<BR> {<BR> <BR> Table tb = (Table)(p.FindControl("TmpTable"));<BR> <BR> if (tb.Controls[0].ID == "checkboxlist")<BR> {<BR> CheckBoxList chklst = (CheckBoxList)(tb.Controls[0]);<BR> <BR> for(int i=0;i &#060;= chklst.Items.Count-1;i++)<BR> { <BR> if (chklst.Items[i].Selected == true)<BR> {<BR> valItem = Convert.ToString(chklst.Items[i].Text);<BR> itemList.Add(valItem);<BR> }<BR> }<BR> }<BR><BR><BR>for some reason teh line <BR>if (tb.Controls[0].ID == "checkboxlist")<BR> does not work,i t just does not go inside the if statement,at runtime when creating the checkboxlist i have the ID of it as "checkboxlist"<BR>any help would be greatly appreciated.<BR>

  2. #2

    Default RE: How to find the control???

    Why do you assume that the CheckBoxList will be the first child control of the table?<BR>Won&#039;t it have rows or cells first?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts