如何在按钮单击时在数据库中插入checkboxlist的选定值后取消选中复选框列表。 [英] how to uncheck the checkboxlist after insert the selected value of checkboxlist in database on button click.

查看:98
本文介绍了如何在按钮单击时在数据库中插入checkboxlist的选定值后取消选中复选框列表。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ddlroom.Text = ""
txtrow.Text = ""
txtcolumn.Text = ""
txtstrength.Text = ""







i使用它来清除文本框的值。但是如何清除checkboxlist中选中的复选框。




i an using this for clear the value of textbox. but how cam i clear the selected checkbox in checkboxlist.

推荐答案

public void CleareAllcontrolsRecursive(Control container)
    {
        foreach (var control in container.Controls)
        {
            if (control is TextBox)
            {
                ((TextBox)control).Text = string.Empty;
            }
            if (control is DropDownList)
            {
                ((DropDownList)control).SelectedValue = "0";
            }
            if (conntrol is CheckBox)
            {
                ((CheckBox)control).Checked = false;
            }
        }
    }





在插入数据后调用此方法按钮单击。



CleareAllcontrolsRecursive(panel1);





你的身体标签...封装panel1标签

< asp:form id =form1runat =serverxmlns:asp =#unknown>

< ; asp:panel id =panel1runat =server>

....控制标签......




call this method button click ,after inserting the data...

CleareAllcontrolsRecursive(panel1);


in your body tag...contails "panel1" tag
<asp:form id="form1" runat="server" xmlns:asp="#unknown">
<asp:panel id="panel1" runat="server">
....controls tags...


在按钮点击事件中尝试此操作:

Try this in button click event:
For Each li As ListItem In CheckBoxList1.Items
	li.Selected = False
Next

这篇关于如何在按钮单击时在数据库中插入checkboxlist的选定值后取消选中复选框列表。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆