| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 827 人关注过本帖
标题:动态添加CHECKBOXLIST出错
只看楼主 加入收藏
nic
Rank: 2
等 级:新手上路
威 望:4
帖 子:175
专家分:0
注 册:2005-11-1
收藏
 问题点数:0 回复次数: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-02-27 12:29
nic
Rank: 2
等 级:新手上路
威 望:4
帖 子:175
专家分:0
注 册:2005-11-1
收藏
得分:0 
ding

2006-02-27 17:31
快速回复:动态添加CHECKBOXLIST出错
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015710 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved