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

RadGrid's NeedDataSource Event Firing on the wrong PageView

2 Answers 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Casey
Top achievements
Rank 1
Casey asked on 22 Apr 2011, 05:09 PM
Hello All,

I have an application that utilizes a RadMultiPage, with both RadButtons and a RadTabStrip used to navigate between RadPageViews. I am currently experiencing an issue with a RadGrid on the third RadPageView (Index 2). I have specified the NeedDataSource event for the RadGrid, however, when I navigate to the RadPageView containing this RadGrid, the event is not fired. The peculiar thing is that the NeedDataSource event fires only once I click a RadButton, or RadTab, to move to any of the other pageviews.

Does anybody have any ideas as to why the event would not fire when that RadPageView is initially selected and instead is firing when I try to navigate away from that RadPageView??

I don't set the DataSource of the RadGrid anywhere else in the code behind; I only set it in the NeedDataSource event. When putting a breakpoint on the NeedDataSource event, the breakpoint is only hit when I click on any tab, or button, that takes me away from "rpvDetails".

Please let me know if you need me to list more code.

Thanks!
Casey

.ASPX page:
<div style="width: 60%; margin-top: 10px; float: left" align="center">
    <div>
        <telerik:RadTabStrip runat="server" ID="rtsLeaveRequestNav" SelectedIndex="0" OnTabClick="rtsLeaveRequestNav_TabClick">
            <Tabs>
                <telerik:RadTab Text="Start & End Dates" TabIndex="0" PostBack="true" Selected="true"
                    Width="150px" PageViewID="rpv1">
                </telerik:RadTab>
                <telerik:RadTab Text="FMLA Info" TabIndex="1" PostBack="true" Width="150px" PageViewID="rpv2">
                </telerik:RadTab>
                <telerik:RadTab Text="Details" TabIndex="2" PostBack="true" Width="150px" PageViewID="rpvDetails">
                </telerik:RadTab>
                <telerik:RadTab Text="Review & Save" TabIndex="3" PostBack="true" Width="150px" PageViewID="rpvReview">
                </telerik:RadTab>
            </Tabs>
        </telerik:RadTabStrip>
    </div>
</div>
<br />
<div style="width: 90%; margin-top: 5px; clear: both">
    <div style="float: left; width: 70%; margin-top: 5px; clear: both">
        <telerik:RadMultiPage ID="rmpLeaveRequest" runat="server" SelectedIndex="0" RenderSelectedPageOnly="true">
            <telerik:RadPageView ID="rpv1" runat="server" TabIndex="0">
            </telerik:RadPageView>
            <telerik:RadPageView ID="rpv2" runat="server" TabIndex="1">
            </telerik:RadPageView>
            <telerik:RadPageView ID="rpvDetails" runat="server" TabIndex="2">
                <div style="width: 95%; margin-top: 5px; clear: both; background-color: #E0E0E0;
                    margin-bottom: 50px" align="center">
                    <br />
                    <table style="border-style: outset; width: 80%; background-color: #E0E0E0; padding-bottom: 10px">
                        <tr>
                            <td style="margin-right: 10px" colspan="2" align="center">
                                <telerik:RadGrid ID="rgLeaveDetails" runat="server" AutoGenerateColumns="false" Width="100%"
                                    ClientSettings-Scrolling-AllowScroll="true" ClientSettings-Scrolling-UseStaticHeaders="true"
                                    ClientSettings-Scrolling-ScrollHeight="90px" OnNeedDataSource="rgLeaveDetails_NeedDataSource">
                                    <MasterTableView TableLayout="Fixed" runat="server" ShowHeadersWhenNoRecords="true"
                                        EnableNoRecordsTemplate="false">
                                        <Columns>
                                            <telerik:GridBoundColumn UniqueName="ACTIVITY_DATE" DataField="ACTIVITY_DATE" HeaderText="Date">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn UniqueName="WORK_CODE" DataField="WORK_CODE" HeaderText="Leave Type">
                                            </telerik:GridBoundColumn>
                                            <telerik:GridBoundColumn UniqueName="HOURS" DataField="HOURS" HeaderText="Duration">
                                            </telerik:GridBoundColumn>
                                        </Columns>
                                    </MasterTableView>
                                </telerik:RadGrid>
                            </td>
                            <td align="center">
                                <table>
                                    <tr>
                                        <td>
                                            <telerik:RadButton ID="rbChooseType" runat="server" Text="Choose Leave Type" Width="115px" ButtonType="StandardButton">
                                            </telerik:RadButton>
                                            <br />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <telerik:RadButton ID="rbEdit" runat="server" Text="Edit" Width="115px" ButtonType="StandardButton">
                                            </telerik:RadButton>
                                            <br />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <telerik:RadButton ID="rbDelete" runat="server" Text="Delete" Width="115px" ButtonType="StandardButton">
                                            </telerik:RadButton>
                                            <br />
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <telerik:RadButton ID="rbDeleteAll" runat="server" Text="Delete All" Width="115px" ButtonType="StandardButton">
                                            </telerik:RadButton>
                                            <br />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    <br />
                    <table style="border-style: outset; width: 80%; background-color: #E0E0E0; padding-bottom: 10px">
                        <tr>
                            <td colspan="3" align="left">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="right">
                            </td>
                            <td align="left">
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="right">
                            </td>
                            <td align="left">
                            </td>
                        </tr>
                    </table>
                    <br />
                    <br />
                    <br />
                </div>
            </telerik:RadPageView>
            <telerik:RadPageView ID="rpvReview" runat="server" TabIndex="3">
            </telerik:RadPageView>
        </telerik:RadMultiPage>


Code Behind Events:
protected void rtsLeaveRequestNav_TabClick(object sender, RadTabStripEventArgs e)
{
    rmpLeaveRequest.SelectedIndex = rtsLeaveRequestNav.SelectedIndex;
}
 
protected void rgLeaveDetails_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    rgLeaveDetails.DataSource = String.Empty;
}

2 Answers, 1 is accepted

Sort by
0
Casey
Top achievements
Rank 1
answered on 22 Apr 2011, 06:25 PM
I've added some additional code to my page to fix this issue. Apparently, the page load and other events, were fired before the TabClick or ButtonClick events where I set the RadMultiPage's selected index, so to fix this, for each event where I set the RadMultiPage's selected index, I Rebind the RadGrid (if the new selected index is 2).

Casey
0
Iana Tsolova
Telerik team
answered on 26 Apr 2011, 09:55 AM
Hi Casey,

Check out the below article for more information:
http://www.telerik.com/help/aspnet-ajax/grid-visible-invisible-conventions.html

Best wishes,
Iana
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Grid
Asked by
Casey
Top achievements
Rank 1
Answers by
Casey
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or