1<table id="OPTTB">2<asp:repeater id="tempoptions"runat="Server">3<ItemTemplate>4<tr ondblclick="tt (this)">5<td><% #Eval ("XH")%></td>6<td><% #Eval ("XXBH")%></td>7<td><% #Eval ("XXMC")%></td>8<td><% #Eval ("ISOK")%></td>9</tr>Ten</ItemTemplate> One</asp:Repeater> A</table>
View Code
HTML Dynamic Table background
1 protected voidDeloption_click (Objectsender, EventArgs e)2 {3 varTemplist =NewList<tablemodel>();4 varDelno = This. Delno.value;5 if(session["tempdate"] !=NULL)6 {7 varTempdata1 = session["tempdate"] asList<tablemodel>;8 9 for(inti =0; I < Tempdata1. Count; i++)Ten { One templist. ADD (Tempdata1[i]); A } - } -Templist. RemoveAt (Convert.ToInt16 (delno.substring (0,1))); the - list. Clear (); - - for(intK =0; K < Templist. Count; k++) + { -TableModel TM =NewTableModel (); +Tm.xh =k.tostring (); ATm. XXBH =Numtochar (k.tostring ()); atTm. XXMC =Templist[k]. XXMC; -Tm. ISOK =Templist[k]. ISOK; -Tm. Remark =Templist[k]. Remark; - list. ADD (tm); - } - in This. Tempoptions.datasource =todatatable (list); - Tempoptions.databind (); to templist. Clear (); + list. Clear (); - the } * $ Panax Notoginseng - protected voidAddoption_click (Objectsender, EventArgs e) the { + if(session["tempdate"] !=NULL) A { the varTempdata1 = session["tempdate"] asList<tablemodel>; + for(inti =0; I < Tempdata1. Count; i++) - { $ list. ADD (Tempdata1[i]); $ } - } -TableModel TM =NewTableModel (); theTm.xh =(list. Count). ToString (); -Tm. XXBH =Numtochar (TM.XH);WuyiTm. XXMC = This. Questions.text; theTm. ISOK = This. ISOK1. Checked = =true?"No":"is a"; -Tm. Remark = This. Remark.text; Wu vartt =ISOK2. Checked; - list. ADD (tm); About This. Tempoptions.datasource =todatatable (list); $ Tempoptions.databind (); -session["tempdate"] =list; - list. Clear (); - } A + the - $ Public StaticDataTable todatatable (IList list) the { theDataTable result =NewDataTable (); the if(list. Count >0) the { -propertyinfo[] Propertys = list[0]. GetType (). GetProperties (); in foreach(PropertyInfo Piinchpropertys) the { the result. Columns.Add (pi. Name, Pi. PropertyType); About } the the for(inti =0; I < list. Count; i++) the { +ArrayList templist =NewArrayList (); - foreach(PropertyInfo Piinchpropertys) the {Bayi Objectobj = pi. GetValue (List[i],NULL); the templist.add (obj); the } - Object[] Array =Templist.toarray (); -Result. Loaddatarow (Array,true); the } the } the returnresult; the}
View Code
HTML Dynamic Table