This is a migrated thread and some comments may be shown as answers.

how do I find PlaceHolder in DetailItemTemplate

1 Answer 132 Views
Grid
This is a migrated thread and some comments may be shown as answers.
moegal
Top achievements
Rank 1
moegal asked on 19 Feb 2013, 04:48 PM
how do I find a PlaceHolder in a DetailItemTemplate

I have added  OnItemDataBound="RadGrid1_ItemDataBound" to RadGrid1

I have tried many different variations.

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        Label lbl = new Label();
        lbl.Text = "Proofs:";
        lbl.CssClass = "cLabel";
 
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            PlaceHolder PlaceHolderProof = (PlaceHolder)item["PlaceHolderProof"].Controls[0];
//PlaceHolder PlaceHolderProof = (PlaceHolder)item.FindControl("PlaceHolderProof");
            PlaceHolderProof.Controls.Add(lbl);
        }
 
    }

i was able to do the following:

GridDataItem item = e.Item as GridDataItem;
        if (item != null)
        {
            RadButton ProofButton = item.DetailTemplateItemDataCell.FindControl("ProofButton") as RadButton;
            string ID = item["Approved"].Text;
 
            if (ID == "0")
            {
                ProofButton.Visible = false;
            }
            else
            {
                ProofButton.Visible = true;
            }
        }


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 21 Feb 2013, 05:31 AM
Hi,

Try the following code.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
         if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
           PlaceHolder pl = (PlaceHolder)item.DetailTemplateItemDataCell.FindControl("PlaceHolder1");
        }
}

Thanks,
Shinu
Tags
Grid
Asked by
moegal
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or