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

findcontrol in dynamic rad Grid

1 Answer 52 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vigneshwaran
Top achievements
Rank 1
Vigneshwaran asked on 15 Jan 2011, 04:23 PM
Hi,

In my dynamic radgrid i create one template column with html image control. But in row data bound i can't find that control.

it come as null. Based on data i want to give image path on that.

any idea? Please help me ASAP.


Thanks
Vignesh

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 17 Jan 2011, 07:03 AM
Hello Vignesh,


If you want to access the control in code behind, then you need to add runat="server" to the html image control, otherwise use server control for the same functionality.

Then use FindControl() to access the control in ItemDataBound.
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem) e.Item;
        HtmlImage img = (HtmlImage)item.FindControl("controlID");
        img.Visible = false;
    }
}



-Shinu.
Tags
Grid
Asked by
Vigneshwaran
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or