c# - Same ID error while adding dynamic controls to table in ASP .NET -
i have added controls dynamically table in asp .net letting user come in required no of rows. sample code of addrow() function is:
htmltablecell cell_1 = new htmltablecell(); htmltablecell cell_2 = new htmltablecell(); l = new label(); nomenclature = new textbox(); unit = new textbox(); row[i] = new htmltablerow(); label.text = "" +(i+ 1); cell_1.controls.add(l); row[i].controls.add(cell_1); nomenclature.textmode = textboxmode.multiline; nomenclature.rows = 5; nomenclature.columns = 40; nomenclature.id="nomenclature"+i; nomenclature.text = "na"; cell_2.controls.add(nomenclature); row[i].controls.add(cell_2); table_items.controls.add(row[i]);
now after adding rows, when refresh page , 1 time again seek add together new rows, gives me sameid 'nomenclature0' error.
please help me regarding this,
thanks in advance,
i havent plenty info code.
two possible solutions:
1) seek "table_items.controls.clear();" before phone call addrows function.
2) if ispostback, dont fill table.
c# html asp.net .net website
No comments:
Post a Comment