Repeater嵌套绑定Repeater

Repeater嵌套绑定RepeaterRepeater嵌套Repeater的结构:一般写过的都能看懂吧cs代码:CodeCodehighlightingproducedbyActiproC

原文地址为:
Repeater嵌套绑定Repeater

Repeater嵌套Repeater的结构:一般写过的都能看懂吧

 cs代码: 

 

ContractedBlock.gif
ExpandedBlockStart.gif
Code

private
 
void
 RpTypeBind()
        {

//
GetQuestionTypeAndCount() 返回一个datatable


            
this
.rptypelist.DataSource 
=
 LiftQuestionCtr.GetQuestionTypeAndCount();                   
            

this
.rptypelist.DataBind();
        }
               

protected
 
void
 rptypelist_ItemDataBound(
object
 sender, RepeaterItemEventArgs e)
        {


//
判断里层repeater处于外层repeater的哪个位置( AlternatingItemTemplate,FooterTemplate,


//
HeaderTemplate,,ItemTemplate,SeparatorTemplate)


            
if
 (e.Item.ItemType 
==
 ListItemType.Item 
||
 e.Item.ItemType 
==
 ListItemType.AlternatingItem)
            {

                Repeater rep 

=
 e.Item.FindControl(

rpquestionlist


as
 Repeater;
//
找到里层的repeater对象


                DataRowView rowv 
=
 (DataRowView)e.Item.DataItem;
//
找到分类Repeater关联的数据项 


                
int
 typeid 
=
 Convert.ToInt32(rowv[

qtid

]); 
//
获取填充子类的id 


                rep.DataSource 
=
 LiftQuestionCtr.GetSomeQuestionsByTypeid(typeid, 
2
);
                rep.DataBind();
            }
        }

 

aspx:

ContractedBlock.gif
ExpandedBlockStart.gif
Code

<
table border
=

0

 cellpadding
=

0

 cellspacing
=

0

 style
=

margin-bottom: 5px

 width
=

100%

>

    

<
asp:Repeater runat
=

server

 ID
=

rptypelist

 OnItemDataBound
=

rptypelist_ItemDataBound

>

        

<
ItemTemplate
>

            

<
tr
>

                

<
td 
class
=

fb

>

                    

&
nbsp;
&
nbsp;
<
a href
=

Lists.aspx?Qtid=<%#Eval(

qtid

) %>

><%
#Eval(

qtypename


%></
a
>
 
<
span id
=

askCount_15


                        

class
=

date2

>
[
<%
#Eval(

typecount

)
%>
]
</
span
>

                

</
td
>

            

</
tr
>

            

<
tr
>

                

<
td
>

                    

<
div id
=

askTop2_15

 
class
=

ask_list

>

                        

<
asp:Repeater runat
=

server

 ID
=

rpquestionlist

>

                            

<
ItemTemplate
>

                                

<
a href
=

Question.aspx?qid=<%#Eval(

liftquestionid

)%>

>

                                    

<%
#Eval(

questiontitle

)
%></
a
><
br 
/>

                            

</
ItemTemplate
>

                        

</
asp:Repeater
>

                    

</
div
>

                

</
td
>

            

</
tr
>

        

</
ItemTemplate
>

    

</
asp:Repeater
>


</
table
>

 

 

 

此方法应该适合于repeater嵌套,datalist嵌套。

(datalist嵌套前不久试过,也可以)

 

转载请注明本文地址:
Repeater嵌套绑定Repeater

今天的文章Repeater嵌套绑定Repeater分享到此就结束了,感谢您的阅读。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/5621.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注