Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Grid > Can't set UserControl Property with Eval (nestedviewtemplate)

Not answered Can't set UserControl Property with Eval (nestedviewtemplate)

Feed from this thread
  • Javier avatar

    Posted on Feb 9, 2012 (permalink)

    I have a usercontrol with a public property that I'm trying to set using Eval with a databound Radgrid.

    I'm trying to set the Acc Property to Eval("Acc").  It just won't stick.  By the time the usercontrol is loaded the property has been reset.

    In the usercontrol, the property is just defined.  It's never set and has no default value.  I've tried to set it in the codebehind in the expand event of the nested view, and it still doesn't stick.

    I've resorted to set it in the control itself with.

    Acc = DirectCast(DirectCast(Me.Parent.Parent, Telerik.Web.UI.GridTableCell).Parent, Telerik.Web.UI.GridNestedViewItem).ParentItem.GetDataKeyValue("Acc")

    Which I don't want to do because this control won't only be used in the gridview.  I'll handle those cases later, for now I just want to get this part working.  The markup is pasted below.  thanks.

    <telerik:RadGrid ID="rgdQueue" runat="server" CellSpacing="0" DataSourceID="dsQueue"
        AllowFilteringByColumn="True" GridLines="None" AllowPaging="true" AllowSorting="true">
        <MasterTableView AutoGenerateColumns="False" DataSourceID="dsQueue" DataKeyNames="Acc">
            <NestedViewTemplate>
                <table style="width: 100%;">
                    <tr>
                        <td>
                            <span style="font-size: 18pt; color: #010101; line-height: 30px;">Report</span>
                        </td>
                    </tr>
                    <tr>
                        <td style="width: 100%;">
                            <div style="border: 1px solid gray; padding-left: 25px; padding-right: 10px; padding-top: 10px;
                                padding-bottom: 10px;">
                                <%# Eval("OriginalReport") %>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <%# Eval("Acc") %>
                            <uc4:PeerReview Acc='<%# Eval("Acc") %>' ID="PRNested" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Button ID="btnSave" runat="server" Text="Save" CausesValidation="true" OnClick="btnSave_Click" ValidationGroup='<%# Eval("Acc") %>' />
                            <asp:Button ID="btnSign" runat="server" Text="Sign" CausesValidation="true" ValidationGroup='<%# Eval("Acc") %>' />
                            <asp:Button ID="btnNext" runat="server" Text="Next" OnClick="btnNext_Click" CausesValidation="false" />
                        </td>
                    </tr>
                </table>
            </NestedViewTemplate>
            <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </RowIndicatorColumn>
            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
            </ExpandCollapseColumn>
            <Columns>          
                <telerik:GridTemplateColumn DataField="QueueDate" FilterControlAltText="View Peer Review History"
                    HeaderText="Date Added to Queue" SortExpression="QueueDate" UniqueName="QueueDate">
                    <ItemTemplate>
                        <asp:Label ID="QueueDateLabel" runat="server" Text='<%# ConvertDateToInternational(Eval("QueueDate")) %>'></asp:Label>
                    </ItemTemplate>
                    <FilterTemplate>
                        <telerik:RadComboBox ID="rcbHistoryFilter" runat="server" OnSelectedIndexChanged="rcbHistoryFilterr_SelectedIndexChanged"
                            OnDataBound="rcbHistoryFilter_DataBound" Width="120" DataSourceID="dsQueueHistory"
                            DataTextField="Text" AutoPostBack="true" DataValueField="Months">
                        </telerik:RadComboBox>
                    </FilterTemplate>
                </telerik:GridTemplateColumn>
                <telerik:GridTemplateColumn HeaderText="Images" UniqueName="Images">
                    <ItemTemplate>
                        <asp:Image Style="border-style: none;" ID="imgViewImages" Acc='<%# Eval("Acc") %>'
                            PatID='<%# Eval("PatientID") %>' SiteCode='<%# Eval("SiteCode") %>' Width="20"
                            Height="20" ImageUrl="../images/workstation.jpg" runat="server"></asp:Image>
                    </ItemTemplate>
                    <FilterTemplate>
                    </FilterTemplate>
                </telerik:GridTemplateColumn>
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
        </HeaderContextMenu>
    </telerik:RadGrid>

    Reply

  • Veli Veli admin's avatar

    Posted on Feb 14, 2012 (permalink)

    Hi Javier,

    The markup you provided seems OK. If the Acc field is rendered in the table cell with this markup:

    <td>
    <%# Eval("Acc") %>
    <uc4:PeerReview Acc='<%# Eval("Acc") %>' ID="PRNested" runat="server" />
    </td>

    this means the databinding works OK. If this issue persists, consider opening a regular support ticket where you can send us a small test project we can use to reproduce the issue. Thus, we can test it locally and advise you further.

    Veli
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

  • Javier avatar

    Posted on Feb 16, 2012 (permalink)

    It works fine for any other control that isn't a user control.  No matter when I try to set the property it will never stick.  The page load event of the usercontrol seems to fire a lot more than necessary with the nested view.  So the property will set, then the usercontrol will reload without the property being set.

    Reply

  • Veli Veli admin's avatar

    Posted on Feb 16, 2012 (permalink)

    Hi Javier,

    Consider opening a regular support ticket where you can send us a small runnable project demonstrating this issue. Thus, we will be able to better understand your scenario and advise you further.

    Veli
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Grid > Can't set UserControl Property with Eval (nestedviewtemplate)
Related resources for "Can't set UserControl Property with Eval (nestedviewtemplate)"

ASP.NET Grid Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]