中继器和复选框

编程入门 行业动态 更新时间:2024-10-18 21:23:59
本文介绍了中继器和复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

ASPX代码:

ASPX code:

<td class="field1"><asp:CheckBox ID="CheckBox1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "PersonnelSummary_Cleveland_Resident") %>'/></td> <td class="field1"><asp:CheckBox ID="CheckBox2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "PersonnelSummary_Present") %>' /></td> <asp:Button ID="btnAddAnother" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Button") %>' CommandName='<%# DataBinder.Eval(Container.DataItem, "Button") %>' />

cs代码:

cs code:

public void Rptr_ItemCommand(Object source, RepeaterCommandEventArgs e) { int Total = Rptr.items.Count; if (e.CommandName == "Add") { Total = Total + 1; AddColumns(); foreach (Repeater item in Rptr.Items) { CheckBox PSR = ((CheckBox)item.FindControl("txtPSR")); CheckBox PSP = ((CheckBox)item.FindControl("txtPSP")); Button btnAdd = ((Button)item.FindControl("btnAddAnother")); } tb.Rows.Add(PSR,PSP, "Add"); } else if (e.CommandName == "Remove") { Total = Total -1; CheckBox PSR = ((CheckBox)item.FindControl("txtPSR")); CheckBox PSP = ((CheckBox)item.FindControl("txtPSP")); Button btnAdd = ((Button)item.FindControl("btnAddAnother")); } } public void AddColumns() { tb.Columns.Add("PSR", typeof(bool)); tb.Columns.Add("PSP", typeof(bool)); tb.Columns.Add("Button") } public void ButtonAdd_Click(object sender, EvenetArgs args) { AddColumns(); tb.Rows.Add(bool, bool, "Add"); btnAddAnother.Visible = false; }

我有两个问题: P1:当用户单击添加按钮时,复选框出现错误.我将布尔值更改为1或0,以表示是非.当我单击复选框以查看是否更改时,答案是否定的. P2:当用户单击以将其删除时,将删除动态创建的最上层

I have two problems: P1: When a user click the add button, I get error on the check boxes. I change the bool to 1 or 0 it comes up true or false. When I click on the checkboxes to see if the change the answer is no. P2: When the user click to remove it remove a dynamically created the very top

推荐答案

tb.Rows.Add(bool, bool, "Add");

这显然是行不通的.布尔是一种类型,而不是值.

This quite obviously won''t work. Bool is a type not a value.

更多推荐

中继器和复选框

本文发布于:2023-11-25 01:56:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627841.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:复选框   中继器

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!