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

Open Radwindow from Radgrid

2 Answers 205 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Agm
Top achievements
Rank 1
Agm asked on 30 Oct 2013, 10:17 PM
Hi,

I want to open Radwindow while clicking on asp:Image within Templatecolumn in Radgrid.

I have pasted my code below.

please help me to get this done.

Thanks in advance.
aspx:
<
telerik:GridTemplateColumn HeaderText="Image" UniqueName="image_file_location"
<
ItemTemplate>
<
asp:Image ID="ImgSign" Width="70" Height="80" runat="server" ImageUrl="test.png" />
</
ItemTemplate>
</
telerik:GridTemplateColumn>

c#:
protected void RadGrid_tab1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            
            DataRowView drv = (DataRowView)e.Item.DataItem;
            GridDataItem item = (GridDataItem)e.Item;
            Image img = (Image)item.Controls[0].FindControl("ImgSign");
    string from=txt_test.Text;
            string url = "test.png_"+from;
            img.Attributes["onclick"] = "return ShowForm("+url+");";
        }
        
    }
Javascript:
<script type="text/javascript">
    function ShowForm(url) {
        alert(url);
        window.radopen(url, "");
    } 
</script> 

Regards,
AGM Raja

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 1
answered on 31 Oct 2013, 04:14 AM
Hi,

Please try the following code snippet. The onclick event can be added in the ItemCreated event of the RadGrid.

ASPX:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server"
</telerik:RadWindowManager>
 
<telerik:GridTemplateColumn UniqueName="Details" HeaderText="Details">
 <ItemTemplate>
    <asp:Image ID="ImgSign" Width="70" Height="80" runat="server" ImageUrl="~/Window/image.jpg" />
 </ItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item = (GridDataItem)e.Item;
        string value = item.GetDataKeyValue("OrderID").ToString();
        Image img = (Image)item.FindControl("ImgSign");
        string url = "Default.aspx";
        img.Attributes.Add("onclick", "dispWindow('" + url + "');return false;");
    }
}

JS:
<script type="text/javascript">
    function dispWindow(url) {
        window.radopen(url, "");
    }
</script>

Thanks,
Princy
0
Agm
Top achievements
Rank 1
answered on 05 Nov 2013, 09:49 PM
Hi Princy,
I have tried the same already.
But i misunderstood the quotes (' ').

Thank you so much.
Regards,
AGM Raja
Tags
Grid
Asked by
Agm
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Agm
Top achievements
Rank 1
Share this question
or