国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 宜川县| 无极县| 江口县| 牟定县| 分宜县| 突泉县| 靖西县| 兴国县| 邓州市| 新宾| 郁南县| 昌吉市| 泽库县| 竹溪县| 建瓯市| 胶南市| 昂仁县| 湘乡市| 杭锦后旗| 宜君县| 中卫市| 密山市| 阳春市| 萨迦县| 天镇县| 来安县| 永定县| 安阳县| 隆回县| 龙游县| 瑞昌市| 思茅市| 银川市| 永康市| 安仁县| 珠海市| 西林县| 新密市| 潞西市| 泌阳县| 新密市|