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

Accessing a GridButtonColumn nested in another grid

3 Answers 166 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Veteran
Mark asked on 08 Feb 2021, 03:01 PM

I have a rad grid nested:

<telerik:RadGrid ID="gvDocs" runat="server" ShowHeader="false" Width="100%" AutoGenerateColumns="false" OnItemCommand="gvDocsDx_ItemCommand" GridLines="None" CssClass="diagCodes" OnItemDataBound="gvDocs_ItemDataBound">
    <MasterTableView BorderWidth="0">
        <Columns>
            <telerik:GridButtonColumn CommandName="DeleteItem" UniqueName="btnDelDoc" ButtonType="PushButton" Text=" Delete "></telerik:GridButtonColumn>
            <telerik:GridBoundColumn DataField="id" UniqueName="id" HeaderText="RefId" Display="false"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="friendlyName"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="pgNum"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="fileNote"></telerik:GridBoundColumn>
        </Columns>
        <NoRecordsTemplate>
            <div class="no-record">No document associations</div>
        </NoRecordsTemplate>
    </MasterTableView>
</telerik:RadGrid>

 

I am trying to navigate to btnDelDoc so I can disable it.  Here is the code I have and I think I am close: (it is not finding the button) HELP!

protected void gvDocs_ItemDataBound1(object sender, GridItemEventArgs e)
{
    if (util.appUserIsReports)
    {
        //RadPushButton btn = e.Item
        //GridDataItem item = e.Item as GridDataItem;
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            RadButton button = item.FindControl("btnDelDoc") as RadButton;
            button.Enabled = false;
        }
    }
}

 


3 Answers, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 1
Veteran
answered on 08 Feb 2021, 03:02 PM
oops I pasted the wrong method.  Its the same code only named ItemDataBound not ItemDataBound1
0
Mark
Top achievements
Rank 1
Veteran
answered on 09 Feb 2021, 02:17 PM
Not sure why I even try to post here.  We have a paid license and it takes DAYS to get a response. :(
0
Accepted
Attila Antal
Telerik team
answered on 11 Feb 2021, 09:04 AM

Hi Mark,

Based on the markup code you shared seems that you are trying to access the Control (Button) of a built-in column. The FindControl() method looks for Controls by ID, and in your case, the "btnDelDoc" is the UniqueName of the column and not the Control's ID.

To access the Controls of built-in columns, check out the instructions from the Accessing Controls of built-in columns article.

You may also refer to the Accessing Values and Controls article when it comes to accessing values, cells, controls in RadGrid.

We have recently published a Blog Post article that shares a few Tips along with Videos for debugging ASP.NET Apps on the server-side, see 6 Server-Side Debugging Tips That Will Make Developing Easier.

Regarding the licenses, please check out the Purchasing & Licensing FAQs article and share the 3rd point with the license owner. The license owner can assign a user under the license who will have the ability to open tickets with the Support Team.

Regards,
Attila Antal
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Veteran
Answers by
Mark
Top achievements
Rank 1
Veteran
Attila Antal
Telerik team
Share this question
or