国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計(jì) > 正文

Repeater動(dòng)態(tài)添加行

2019-11-17 01:42:34
字體:
供稿:網(wǎng)友

Repeater動(dòng)態(tài)添加行

<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; }


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 千阳县| 景东| 晋江市| 玉田县| 革吉县| 中西区| 福海县| 蓝山县| 大冶市| 平阴县| 商丘市| 志丹县| 新民市| 临安市| 扬中市| 麻栗坡县| 承德市| 星座| 罗定市| 莱阳市| 伊宁县| 益阳市| 迁安市| 高清| 松原市| 盱眙县| 苍梧县| 玉山县| 韶关市| 丰县| 九江市| 无棣县| 古蔺县| 花莲市| 台北县| 建湖县| 鄂托克旗| 漯河市| 青海省| 平度市| 罗山县|