c# - can not find dynamic html select in code behind -
i have class named "row" has 3 item {property,instance,degree}. want show items or rows user , if changed third part of class edit it. code of generating rows dynamically, numberofinstance number of rows.
<div id="hidden" class="hiddendiv"> <% string matn = ""; (int = 0; < numberofinstance ; i++) { row r= new row(); r = a[i]; matn+= " <div class='cmsdiv'>"; matn += "<input id='text"+i+"' class='labelhid' type='text'"+"value = '"+r.property+ "'/>"; matn += "<input id='text2" + + "' class='labelhid' type='text'" + "value = '" + r.instance+ "'/>"; matn += " <select id='select" +i+ "'class='drophid' runat='server'>"; matn += " <option value= '"+ "خیلی زیاد"+"'>خیلی زیاد" + " <option value= '"+"زیاد'"+">زیاد"; matn += " <option value='"+"متوسط'"+">متوسط"; matn += " <option value='" + "کم'" + ">کم"; matn += "</select>"; matn += "</div>"; response.write(matn); matn = ""; } %> </div>
now if user clicked on select , choose 1 option, it's value , pour r.degree in code behind. whatever did couldn't find in code behind , null. these attempts:
var val = request["select" + i]; string selection = request.form["select" + i]; hd = (hiddenfield)page.findcontrol("select" + i); hd = (hiddenfield)control.findcontrol("select" + i);
you can't generate server side controls response.write (more info here). html elements writing output client side controls not server side , cannot found using page.findcontrol method.
consider using 1 of server side controls repeater instead.
Comments
Post a Comment