Checkboxlist检查/取消选中事件 [英] Checkboxlist check/uncheck event

查看:386
本文介绍了Checkboxlist检查/取消选中事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个复选框列表



< asp:CheckBoxList id =check1AutoPostBackTrueTextAlignRightOnSelectedIndexChanged =Checkrunatserver >









功能:



子检查(ByVal发送者为对象,ByVal e As EventArgs)

Dim sql As String

如果check1.SelectedItem。 Selected = True然后[code] ....



错误是:对象引用未设置为对象的实例。有没有更好的方法来检查列表项是否已选中或未选中?

I have a checkboxlist

<asp:CheckBoxList id="check1" AutoPostBack"True" TextAlign"Right" OnSelectedIndexChanged="Check" runat"server">




And the function:

Sub Check(ByVal sender As Object, ByVal e As EventArgs)
Dim sql As String
If check1.SelectedItem.Selected = True Then[code]....

The error is: Object reference not set to an instance of an object. Is there a better way to check if a list item is checked or unchecked?

推荐答案

尝试以下



Try the following

if (Checkboxlist1.Items[Index].Selected)
            {
                Response.Write("Try this");
            }


这篇关于Checkboxlist检查/取消选中事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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