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

accessing button of radgrid ItemTemplate in code behind

2 Answers 363 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Naresh
Top achievements
Rank 1
Naresh asked on 13 Jun 2011, 03:30 PM
Hi,

I'm new to Rad Controls, can any one please help me to resolve this issue

I have one RadGrid, in this I placed one gridtemplatecolumn which contains one panel. This panel contains two buttons and one label. I'm using this panel as popup.

My problem is when i click on fist button(Delete) the row should delete and when I click on link(Cancel) the panel should hide.
I'm not getting how to access this button and link in code behind.

this is my code..

<Code>
<telerik:GridTemplateColumn UniqueName="DeletePopup">
                                        <ItemTemplate>
                                            <asp:LinkButton ID="PopupImgButton" CssClass="useredit" Text="Delete"
                                                runat="server" OnClientClick="this.disabled=true;__doPostBack(this.name,'');return false;" />
                                            <asp:Panel ID="PopUpPanel" runat="server" BackColor="White" BorderColor="Red" BorderStyle="Solid"
                                                BorderWidth="1px" Width="809px" Height="25px" CssClass="edit">
                                                <div>
                                                <asp:Button ID="Button1" runat="server" Text="Delete" CommandName="Deletebtn" OnClientClick="this.disabled=true;__doPostBack(this.name,'');" />
                                                    <asp:Label ID="Label1" runat="server"  Text="Are you sure you want to delete [John Smithfield]? This cannot by undone."></asp:Label>
                                                    <a href="#" class="NormalCloseLink" style="padding-left:300px;color:Blue">CANCEL</a>
                                                </div>
                                            </asp:Panel>
                                            <asp:PopupControlExtender ID="ImgPopupControlExtender" runat="server" TargetControlID="PopupImgButton"
                                                PopupControlID="PopUpPanel" Position="Top" OffsetX="-745" OffsetY="7">
                                            </asp:PopupControlExtender>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
 </Code>

please give me some solution for this...

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 13 Jun 2011, 07:03 PM
Hi,

please see below link and let me know if any concern.

.aspx page code
<telerik:GridTemplateColumn UniqueName="DeletePopup">
    <ItemTemplate>
        <asp:LinkButton ID="LnkOpenPopup" runat="server" CommandName="OpenPopup" onclick="lnkOpenPopup_Click">
        <ajax:ModalPopupExtender ID="mp1">
        <asp:Panel>
            <asp:Button ID="btnDelete" onclick="btnDelete_Click">
            <asp:Button ID="btnClose" onclick="btnClose_Click">
        </asp:Panel>
    </ItemTemplate>
</telerik:GridTemplateColumn>

.aspx.cs page code

lnkOpenPopup_Click()
{
    LinkButton LnkOpenPopup = (LinkButton)sender;
           GridDataItem item = (GridDataItem)LnkOpenPopup.NamingContainer;
           ModalPopupExtender mp1= (ModalPopupExtender)item.FindControl("mp1");
           mp1.Show()
}

btnDelete_Click()
{
    Button btnDelete= (Button)sender;
           GridDataItem item = (GridDataItem)btnDelete.NamingContainer;
           ModalPopupExtender mp1= (ModalPopupExtender)item.FindControl("mp1");
           mp1.Hide();
    // string ID = item.GetDataKeyValue("ID").ToString(); // get data key value for delete
}

btnClose_Click()
{
    Button btnClose= (Button)sender;
           GridDataItem item = (GridDataItem)btnClose.NamingContainer;
           ModalPopupExtender mp1= (ModalPopupExtender)item.FindControl("mp1");
           mp1.Hide();
}




Thanks,
Jayesh Goyani
0
Naresh
Top achievements
Rank 1
answered on 14 Jun 2011, 08:52 AM
Hi Jayesh,

 Thanks for your quick reply...

It's working fine with this code but the problem is, the popup should display on top of the respected row but it displays in constant place.
I'm not getting how to display that on respected row. Could you please check this...
If possible, please use popupcontrolextender
Tags
Grid
Asked by
Naresh
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Naresh
Top achievements
Rank 1
Share this question
or