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

[Solved] Problem in finding the Image button from detailtable of radgrid

1 Answer 249 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rekha Kardam
Top achievements
Rank 1
Rekha Kardam asked on 02 Dec 2009, 12:14 PM
Hi, 
 
I am using the radgrid with MasterTableView and DetailTables,in the detailTable ,there is GridTableView. 
In the GridTableView ,i have itemtemplate(Image button) column,my requirement is i want to bind the image url for that image button but i am unable to find the image button in the radgrid item data bound event.i am attaching the code below,please help me how i can aceive this : 

<
rad:RadGrid ID="radGridPlans" runat="server" 
            Skin="Outlook2007" 
            AutoGenerateColumns="False" 
            Width="100%" GridLines="None" 
            AllowPaging="True" PageSize="100" 
            AllowMultiRowSelection="True" 
            EnableAjax="True" EnableAJAXLoadingTemplate="True" LoadingTemplateTransparency="80"    > 
            <MasterTableView 
                DataKeyNames="PlanMstrID" Name="PlanMasters" 
                CommandItemDisplay="Top" 
                EditMode="InPlace" Width="100%" 
                GroupsDefaultExpanded="False" 
                NoMasterRecordsText="Please select an item in the list on the left."
                <DetailTables  > 
                    <rad:GridTableView DataKeyNames="PlanID" Name="PlanHeaders" Width="100%" runat="server"  > 
                        <Columns> 
                            <rad:GridClientSelectColumn UniqueName="SelectColumn"
                                <HeaderStyle Width="16px" /> 
                            </rad:GridClientSelectColumn> 
                     
                         
                            <rad:GridTemplateColumn UniqueName="EditColumn" > 
                                <HeaderStyle Width="16px"></HeaderStyle> 
                                <ItemStyle HorizontalAlign="Center"></ItemStyle> 
                                <ItemTemplate> 
                                    <asp:ImageButton ID="btnEditPlan" runat="server" CommandName="EditPlan" ImageUrl="~/Images/Edit.gif"
                                    </asp:ImageButton> 
                                </ItemTemplate> 
                            </rad:GridTemplateColumn> 
                            <rad:GridButtonColumn UniqueName="DeleteColumn"    CommandName="DeletePlan" Text="Delete plan..." 
                                ConfirmText="Are you sure you want to delete this plan?" ButtonType="ImageButton" 
                                ImageUrl="~/Images/Delete.gif" 
                            > 
                                <HeaderStyle Width="16px" /> 
                                <ItemStyle HorizontalAlign="Center" Height="16px" Width="16px"    /> 
                            </rad:GridButtonColumn> 
                            <rad:GridBoundColumn UniqueName="PlanID" DataField="PlanID" HeaderText="PlanId" Visible="False"
                            </rad:GridBoundColumn> 
                            <rad:GridBoundColumn UniqueName="PlanVersion" DataField="PlanVersion" HeaderText="Version"
                            </rad:GridBoundColumn> 
                            <rad:GridBoundColumn UniqueName="PlanVersionDesc" DataField="PlanVersionDesc" HeaderText="Description"
                            </rad:GridBoundColumn> 
                            <rad:GridBoundColumn UniqueName="PlanStatusName" DataField="PlanStatusName" HeaderText="Status"
                            </rad:GridBoundColumn> 
                            <rad:GridBoundColumn UniqueName="PlanRevenueType" DataField="PlanRevenueType" HeaderText="Revenue Type" Visible="False"
                            </rad:GridBoundColumn> 
                             <rad:GridTemplateColumn UniqueName="RevenueType" DataField="PlanRevenueTypeID" HeaderText="Rev. Mode"
                                <HeaderStyle HorizontalAlign="Center" ></HeaderStyle
                                <ItemStyle HorizontalAlign="Center"></ItemStyle> 
                                <ItemTemplate> 
                                     <asp:Image  ID="imgRevType" runat="server" ImageUrl="" ToolTip="Room Revenue Type: Full Calendar=Monthly Revenues; Multiple Days=Daily Revenues..." /> 
                                </ItemTemplate> 
                            </rad:GridTemplateColumn> 
                             
                            <rad:GridBoundColumn UniqueName="LastEditUser" DataField="LastEditUser" HeaderText="Last Edited By"
                            </rad:GridBoundColumn> 
                            <rad:GridBoundColumn UniqueName="LastEditTS" DataField="LastEditTS" HeaderText="Last Edited" 
                                DataFormatString="{0:MM/dd/yyyy hh:mm tt}" 
                            > 
                            </rad:GridBoundColumn> 
                            <rad:GridBoundColumn UniqueName="PlanMstrFiscalYear" DataField="PlanMstrFiscalYear" HeaderText="PlanMstrFiscalYear" Visible="False"
                            </rad:GridBoundColumn> 
                        </Columns> 
                        <RowIndicatorColumn> 
                            <HeaderStyle Width="20px" /> 
                        </RowIndicatorColumn> 
                        <ExpandCollapseColumn> 
                            <HeaderStyle Width="20px" /> 
                        </ExpandCollapseColumn> 
                    </rad:GridTableView> 
                </DetailTables> 
                <CommandItemTemplate> 
                    <div style="padding:3px 3px;" > 
                        <asp:LinkButton ID="btnNewPlan" runat="server" CommandName="NewPlan"
                            <img style="border:0px;vertical-align:Middle;" src="~/Images/New.gif" runat="server" alt="" /> 
                            Create New Plan... 
                        </asp:LinkButton> 
                        &nbsp; 
                        <asp:LinkButton ID="btnDeletePlan" runat="server" CommandName="DeleteSelected" 
                            OnClientClick="javascript:return confirm('Delete selected plan(s)?')" > 
                            <img style="border:0px;vertical-align:Middle;" src="~/Images/Delete.gif" runat="server" alt="" /> 
                            Delete selected plan(s)... 
                        </asp:LinkButton> 
                    </div> 
                </CommandItemTemplate> 
                <Columns> 
                    <rad:GridBoundColumn UniqueName="PlanMstrId" DataField="PlanMstrId" HeaderText="PlanMstrId" Visible="False"
                    </rad:GridBoundColumn> 
                    <rad:GridBoundColumn UniqueName="PropName" DataField="PropName" HeaderText="Property"
                    </rad:GridBoundColumn> 
                    <rad:GridBoundColumn UniqueName="PlanTypeName" DataField="PlanTypeName" HeaderText="Type"
                    </rad:GridBoundColumn> 
                    <rad:GridBoundColumn UniqueName="PlanMstrFiscalYear" DataField="PlanMstrFiscalYear" HeaderText="Year"
                    </rad:GridBoundColumn> 
                    <rad:GridBoundColumn UniqueName="PlanStatusName" DataField="PlanStatusName" HeaderText="Status"
                    </rad:GridBoundColumn> 
                    <rad:GridBoundColumn UniqueName="PlanVersions" DataField="PlanVersions" HeaderText="Versions"
                    </rad:GridBoundColumn> 
                    <rad:GridBoundColumn UniqueName="PlanHeaderLastEditTS" DataField="PlanHeaderLastEditTS" HeaderText="Last Edited" 
                        DataFormatString="{0:MM/dd/yyyy}" 
                    > 
                    </rad:GridBoundColumn> 
                </Columns> 
                <RowIndicatorColumn> 
                    <HeaderStyle Width="20px" /> 
                </RowIndicatorColumn> 
                <ExpandCollapseColumn Visible="True"
                    <HeaderStyle Width="20px" /> 
                </ExpandCollapseColumn> 
                <PagerStyle Mode="NextPrevNumericAndAdvanced" Position="Top" /> 
            </MasterTableView> 
            <ClientSettings 
                EnableClientKeyValues="True" 
            > 
                <Selecting AllowRowSelect="True" /> 
                <Resizing AllowColumnResize="True" EnableRealTimeResize="True" /> 
                <Scrolling    UseStaticHeaders="True"/> 
            </ClientSettings> 
            <SortingSettings SortedBackColor="212, 208, 200" /> 
        </rad:RadGrid> 
======================================================================================================================
i want to find image button "btnEditPlan" from the above source and bind the Image URL for that in the item data bound.
 
 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Dec 2009, 01:06 PM
Hi,

Try accessing the ImageButton in the child table using its Name property as shown below:

C#
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)  
        {  
            if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "PlanHeaders")  
            {  
                GridDataItem dataItem = (GridDataItem)e.Item;  
                ((ImageButton)dataItem["EditColumn"].FindControl("btnEditPlan")).ImageUrl = "";  
 
            }  
        } 


Thanks,
Princy

Tags
Grid
Asked by
Rekha Kardam
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or