c# - Adding rows to <table> dynamically -


i have following table in asp.net:

 <table style="width: 98%" id="tblotherdoc">     <tr>        <td style="width: 10; text-align: left;">           <span">documents:</span>        </td>     </tr>     <tr>        <td>           <asp:hiddenfield id="hidotherpath" runat="server" value='<%# bind("uploadlocationother") %>' />           <a href="#" style="font-size: 12px; color: #2014ff; float: left; vertical-align: middle" onclick="uploadnew(this)">add other</a> <span style="float: left;">           <asp:checkbox id="cbother" runat="server" onclick="otherdocsclicked(this)" checked='<%# bind("otherattached") %>' /></span>           <a href="#" style="font-size: 12px; color: #2014ff; float: left; vertical-align: middle" onclick="downloadfile(this)" title="docother">view</a>         </td>      </tr>   </table> 

each time checkbox clicked, add new exact row table using jquery (so multiple documents can added).

// add new area other document attachements     function otherdocsclicked(row) {         var ischecked = $(row).closest("tr").find("input[type=checkbox][id*=cbother]").is(':checked');          if (ischecked == true) {             var clone = $('#tblotherdoc tbody>tr:last').clone(true);             clone.find("input[type='hidden'], select").val("");                           clone.find("input[type='checkbox'], checked").removeattr('checked');             clone.insertafter('#tblotherdoc tbody>tr:last');         }     } 

i know how add these rows dynamically using c# when return list of documents have been added.

or alternatively, if thinks there's better way appreciate input since solution come , seems giving me more trouble else.

you can use asp.net table control:

table control

eg. adding row in c# code:

tablerow row = new tablerow();                 tablecell cell = new tablecell();                 cell.controls.add(new textbox());                 row.cells.add(cell);                 table.rows.add(row); 

in .aspx page:

<asp:table id="table" runat="server" />  

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -