开发者

How do you access one repeater's control into another repeater's OnItemCommand() method?

lets say I want to make a label of repeater1 visible in repater2'开发者_高级运维s ItemCommand() method..

e.Item.FindControl("rpt1Label").Visible=True;

is not working..how else do you do it ?

[EDIT]

changed that to repeater1.FindControl("rpt1Label").Visible=True;

This is throwing object reference null exception


inside the repeater (normal way to do it for a repeater):

Label thisLabel = (Label)e.item.findcontrol("rpt1Label");

if(thislabel != null 
{
   thislabel.visible = true;
}

if you have a 2nd repeater nested in your first repeater:

Repeater thisRepeater = (Repeater)e.Item.FindControl("repeaterName");
Label thisLabel = (Label)thisRepeater.findcontrol("rpt1Label"); 

if(thislabel != null  
{ 
   thislabel.visible = true; 
} 

Normally it should just be possible to acces the repeater1 from repeater2 by accessing:

(Label) thisLabel = (Label)this.repeater1.findcontrol("labelname");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜