<table class="table table-striped table-bordered table-hover"> <asp:Repeater ID="rp_List" runat="server" onitemcommand="rp_List_ItemCommand"> <HeaderTemplate> <thead> <tr> <th> ID </th> <th> 中文內(nèi)容 </th> <th> 英文內(nèi)容 </th> <th> 是否上傳聲音<%--(添加時(shí)<span class="text-danger">必填</span>)--%> </th> <th width="80px"> 頭像 </th> <th width="80px"> 對(duì)話排序 </th> <th width="80px"> 最大時(shí)間 </th> <th width="80px"> 聲音時(shí)間 </th> <th> 操作 </th> </tr> </thead> </HeaderTemplate> <ItemTemplate> <tr> <td> <%# Container.ItemIndex+1 %> <asp:HiddenField ID="hidid" runat="server" Value='<%#Eval("id") %>' /> </td> <td> <asp:TextBox ID="txtCountentzh" runat="server" Text='<%#Eval("Contentzh") %>' class="form-control"></asp:TextBox> </td> <td> <asp:TextBox ID="txtCountenten" runat="server" Text='<%#Eval("Contenten") %>' class="form-control"></asp:TextBox> </td> <td> <%--<asp:FileUpload ID="FileUpload" runat="server" CSSClass="form-control" />--%> <asp:Label ID="lblsound" runat="server" Text='<%#Eval("IsHave") %>'></asp:Label> </td> <td> <asp:TextBox ID="txtPhoto" runat="server" class="form-control" Text='<%#Eval("photo") %>'></asp:TextBox> </td> <td> <asp:TextBox ID="txtOrder" runat="server" class="form-control" Text='<%#Eval("orderby") %>'></asp:TextBox> </td> <td> <asp:TextBox ID="txtMaxsecond" runat="server" class="form-control" Text='<%#Eval("maxsecond") %>'></asp:TextBox> </td> <td> <asp:TextBox ID="txtSoundSize" runat="server" class="form-control" Text='<%#Eval("soundsize") %>'></asp:TextBox> </td> <td> <%--<a href="DuihuaDelete.aspx?id=<%#Eval("id") %>&page=<%=CurrentPage %>&pianzhangid=<%=pzid %>" class="btn btn-danger" onclick="return confirm('是否刪除該數(shù)據(jù)')">刪除</a>--%> <%--<a href="DuihuaEdit.aspx?id=<%#Eval("id") %>&pianzhangid=<%=pzid %>" class="btn btn- 后臺(tái)代碼: protected void btnAddNewRow_Click(object sender, EventArgs e){ //首先,恢復(fù)數(shù)據(jù)源 DataTable dt = DefineDataTableSchema(hfRptColumns.Value); foreach (RepeaterItem item in rp_List.Items) { DataRow newRow = dt.NewRow(); newRow["id"] = ((HiddenField)item.FindControl("hidid")).Value; newRow["Contentzh"] = ((TextBox)item.FindControl("txtCountentzh")).Text; newRow["Contenten"] = ((TextBox)item.FindControl("txtCountenten")).Text; newRow["photo"] = ((TextBox)item.FindControl("txtPhoto")).Text; newRow["orderby"] = ((TextBox)item.FindControl("txtOrder")).Text; newRow["maxsecond"] = ((TextBox)item.FindControl("txtMaxsecond")).Text; newRow["IsHave"] = ((Label)item.FindControl("lblsound")).Text; newRow["soundsize"] = ((TextBox)item.FindControl("txtSoundSize")).Text; dt.Rows.Add(newRow); } //添加一行 DataRow row = dt.NewRow(); row["Contentzh"] = ""; row["Contenten"] = ""; row["photo"] = ""; row["orderby"] = "0"; row["maxsecond"] = "1"; row["IsHave"] = "未上傳"; row["soundsize"] = "1"; dt.Rows.Add(row); rp_List.DataSource = dt; rp_List.DataBind(); } /// <summary> /// 根據(jù)repeater相對(duì)應(yīng)的列名,定義數(shù)據(jù)源datatable的schema /// </summary> /// <param name="columns">列名</param> /// <returns></returns> public DataTable DefineDataTableSchema(string columns) { DataTable dt = new DataTable(); string[] columnsAry = columns.Split(','); foreach (string str in columnsAry) { dt.Columns.Add(str); } return dt; }
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注