| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY 
共有 314 人关注过本帖
标题:动态添加CHECKBOXLIST出错
收藏  订阅  推荐  打印 
nic
Rank: 2
等级:注册会员
威望:4
帖子:175
积分:1850
注册:2005-11-1
动态添加CHECKBOXLIST出错

想要采用动态添加CHECKBOXLIST的方法,经过实验,产生错误。如果myCheckboxlist.onselectedindexchanged="changed"去掉就可以生成了,可是没有这个就没有意义了,到底要怎么解决,请大家帮忙一下。

编译器错误信息: BC30390: “System.Web.UI.WebControls.ListControl.Protected Overridable Sub OnSelectedIndexChanged(e As System.EventArgs)”是“Protected”,因此它在此上下文中无法访问。

源错误:

行 35: myCheckboxlist.textalign=textalign.right
行 36: myCheckboxlist.autopostback="true"
行 37: MyCheckboxlist.onselectedindexchanged="changed"
行 38: dim myListItem as listitem
行 39: dim j as integer=0

<%@ Page Language="VB" %>
<script runat="server">

' Insert page code here
'
sub page_load(sender as object,e as eventargs)
getCheckboxlist()
end sub

sub getCheckboxlist()
dim i as integer=0
for i=0 to 5
'生成新的行
dim r as tablerow=new tablerow
dim rid as string="R" & i.tostring()
r.id=rid
'生成表行的第一个CELL
dim c1 as tablecell=new tablecell
dim c1id as string="C1" & i.tostring()
c1.id=c1id
c1.text="Checkboxlist No:" +i.tostring()
r.cells.add(c1)
'生成表行的第二个CELL
dim c2 as tablecell=new tablecell
dim c2id as string="c2" +i.tostring()
c2.id=c2id
r.cells.add(c2)
'生成一个CHECKBOXLIST
dim mycheckboxlist as checkboxlist=new checkboxlist()
dim myCheckBoxListID AS string="A" & I.tostring()
mycheckboxlist.id=myCheckBoxListID
myCheckboxlist.repeatColumns="4"
myCheckboxlist.repeatdirection=repeatdirection.horizontal
myCheckboxlist.repeatlayout=repeatlayout.table
myCheckboxlist.textalign=textalign.right
myCheckboxlist.autopostback="true"
MyCheckboxlist.onselectedindexchanged="changed"
dim myListItem as listitem
dim j as integer=0
'为CHECKBOXLIST填充LISTITEM
for j=0 to 7
mylistitem=new listitem
mylistitem.text="aaa"+j.tostring
mylistitem.value="yyy"+j.tostring
mycheckboxlist.items.add(mylistitem)
next
c2.controls.add(mycheckboxlist)
t1.rows.add(r)

next

end sub

sub changed(sender as object,e as eventargs)

end sub

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<!-- Insert content here -->
<asp:Table id="t1" runat="server"></asp:Table>

</form>
</body>
</html>

搜索更多相关主题的帖子: CHECKBOXLIST  动态  
2006-2-27 12:29
nic
Rank: 2
等级:注册会员
威望:4
帖子:175
积分:1850
注册:2005-11-1

ding

2006-2-27 17:31
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.052543 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved