asp.net - Cannot FindControl within dynamically generated table -


i have dynamically generated table , each row in table there form textboxes user complete , submit form. problem i'm having accessing values within these fields once submitted.

the table has id=tableassigneechildren

this html produced 1 of textboxes i'm attempting access:

<input name="ctl00$contentplaceholder1$tchildname1" type="text" value="test name" id="tchildname1" /> 

the code below using test if can access above textbox:

protected sub btnsubmit_click(sender object, e system.eventargs) handles btnsubmit.click      dim childid integer      childid = 1 cint(ichild.value)          response.write(directcast(tableassigneechildren.findcontrol("tchildname" & childid), textbox).text & "<br />")      next  end sub 

thanks in advance help. j.

dynamically created controls lost on every postback. recommend adding table markup because of following reasons:

  1. people run problems there usercontrols not showing.

  2. usercontrols events not getting fired, because usercontrols not exist in markup instead dynamically generated.

  3. there no difference in speed(page-size). can toggle there visibility according needs.

  4. much cleaner, elegant solution.

anyways if need adding table dynamically, have @ question dynamic controls , postback , tutorial http://www.4guysfromrolla.com/articles/092904-1.aspx


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -