LinkButton lnkBtnRemove = (LinkButton)Repeater1.Items[0].FindControl("lnkRemove");

            lnkBtnRemove.Visible = false;

i used above code to make visible false of a link button i have placed in a repeater control.but it gives me a error of

"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"

i'm trying use this code in Page_Load.Pls help....

Recommended Answers

Hi,

Check this link for an answer for finding a control in a Repeater control.

Repeater Control Example

Jump to Post

All 4 Replies

LinkButton lnkBtnRemove = (LinkButton)Repeater1.Items[0].FindControl("lnkRemove");

            lnkBtnRemove.Visible = false;

i used above code to make visible false of a link button i have placed in a repeater control.but it gives me a error of

"Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index"

i'm trying use this code in Page_Load.Pls help....

I think, the issue can be that none has been found. So the lnkBtnRemove is not initialized.

You can find more easily in repeater control

For TextBox write this
string str1 = ((TextBox)e.Item.FindControl("TextBox1")).Text;

and for label write this
((Label)e.Item.FindControl("Label1")).Visible = true;

for link write this
((LinkButton)e.Item.FindControl("LinkEdit")).Visible = true;

use it it will definitively work and to view more detail on repeater control see here

Mr draxous,
Did it help you to solve your problem. if need more help then please ask.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.