Click here to Skip to main content
15,867,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have a Telerik RadGrid that is using a MasterTableView and a DetailTable. Within the DetailsTable there is a GridTableView which looks like this:


<pre><DetailTables>
                <telerik:GridTableView Name="AssignmentGrid" Width="100%"
                    DataKeyNames="ComplaintID,AssignmentID" NoDetailRecordsText="No Assignments Have been Entered" CommandItemDisplay="None" EnableNoRecordsTemplate="true" HierarchyDefaultExpanded="false" AllowSorting="false">
                    <NoRecordsTemplate>
                        <asp:Label ID="Label8" runat="server" CssClass="label" Text="No Work Assigments have been added." />
                    </NoRecordsTemplate>
                    <CommandItemSettings ShowRefreshButton="False" />
                    <Columns>
                        
                    </Columns>
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="ComplaintID" MasterKeyField="ComplaintID" />
                    </ParentTableRelation>
                </telerik:GridTableView>
            </DetailTables>


I want to format some of the data within the Details GridTableView but can't figure it out, or find any documentation for help. Within the MasterTableView I use this code to highlight data within the cells, and it works fine.


C#
<pre>protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem && e.Item.OwnerID == "ctl00_MainContent_RadGrid1_ctl00") 
        {
            //Get the instance of the right type
            GridDataItem dataBoundItem = e.Item as GridDataItem;
            if (dataBoundItem["IsPriority"].Text == "Y")
            {
                dataBoundItem["IsPriority"].ForeColor = Color.Red;
                dataBoundItem["IsPriority"].Font.Bold = true;
                dataBoundItem["IsPriority"].Text = "YES";

            }


What I have tried:


protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridDataItem && e.Item.OwnerID == "ctl00_MainContent_RadGrid1_ctl00") 
        {
            //Get the instance of the right type
            GridDataItem dataBoundItem = e.Item as GridDataItem;
            if (dataBoundItem["IsPriority"].Text == "Y")
            {
                dataBoundItem["IsPriority"].ForeColor = Color.Red;
                dataBoundItem["IsPriority"].Font.Bold = true;
                dataBoundItem["IsPriority"].Text = "YES";

            }
Posted
Updated 28-Apr-21 9:23am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900