Accessing controls defined inside DataRepeater within Page_Load
- by xander
I have a series of controls, 3 of which I need to disable.
protected void AddToCart_Click(object sender, CommandEventArgs e) {
//some other code...
LinkButton ctrl = (LinkButton)sender;
RepeaterItem rpItem = ctrl.NamingContainer as RepeaterItem;
if (rpItem != null) {
LinkButton btn = (LinkButton)rpItem.FindControl("btnRemoveFromCart");
btn.Visible = true;
btn = (LinkButton)rpItem.FindControl("btnAddToCart");
btn.Visible = false;
Image img = (Image)rpItem.FindControl("imgAdded");
img.Visible = true;
}
I want to access the DataRepeater and get to the controls to disable them. Only on Page_Load.
protected void Page_Load(object sender, EventArgs e) {
string galleryID = Session["selectedGalleryID"].ToString();
getItems();
if (!IsPostBack) {
h1GalleryTitle.InnerText = Session["selectedGalleryName"].ToString();
//the code will go here to initially disable the controls that need to be disabled...
}
}