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>10</ItemTemplate>11</asp:Repeater>12</table>
View Code
html动态表格后台
1PRotectedvoidDelOption_Click(objectsender, EventArgs e)2{3vartemplist =newList<tableModel>();4varDelNO =this.DelNO.Value;5if(session["tempdate"] !=null)6{7vartempdata1 = Session["tempdate"]asList<tableModel>;89for(inti =0; i < tempdata1.Count; i++)10{11templist.Add(tempdata1[i]);12}13}14templist.RemoveAt(Convert.ToInt16(DelNO.Substring(0,1)));1516list.Clear();1718for(intk =0; k < templist.Count; k++)19{20tableModel tm =newtableModel();21tm.XH =k.ToString();22tm.XXBH =NumtoChar(k.ToString());23tm.XXMC =templist[k].XXMC;24tm.ISOK =templist[k].ISOK;25tm.Remark =templist[k].Remark;26list.Add(tm);27}2829this.tempOptions.DataSource =ToDataTable(list);30tempOptions.DataBind();31templist.Clear();32list.Clear();3334}35363738protectedvoidaddOption_Click(objectsender, EventArgs e)39{40if(Session["tempdate"] !=null)41{42vartempdata1 = Session["tempdate"]asList<tableModel>;43for(inti =0; i < tempdata1.Count; i++)44{45list.Add(tempdata1[i]);46}47}48tableModel tm =newtableModel();49tm.XH =(list.Count).ToString();50tm.XXBH =NumtoChar(tm.XH);51tm.XXMC =this.Questions.Text;52tm.ISOK =this.ISOK1.Checked ==true?"否":"是";53tm.Remark =this.Remark.Text;54vartt =ISOK2.Checked;55list.Add(tm);56this.tempOptions.DataSource =ToDataTable(list);57tempOptions.DataBind();58Session["tempdate"] =list;59list.Clear();60}6162636465publicstaticDataTable ToDataTable(IList list)66{67DataTable result =newDataTable();68if(list.Count >0)69{70PropertyInfo[] propertys = list[0].GetType().GetProperties();71foreach(PropertyInfo piinpropertys)72{73result.Columns.Add(pi.Name, pi.PropertyType);74}7576for(inti =0; i < list.Count; i++)77{78ArrayList tempList =newArrayList();79foreach(PropertyInfo piinpropertys)80{81objectobj = pi.GetValue(list[i],null);82tempList.Add(obj);83}84object[] array =tempList.ToArray();85result.LoadDataRow(array,true);86}87}88returnresult;89}
View Code