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

Two Grids are not working on the same page

3 Answers 338 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mubasshar
Top achievements
Rank 1
Mubasshar asked on 14 Jul 2011, 01:17 PM
i am trying to use two rad grid on the same page. the grid is working fine but i am unable to see the second grid. i am getting the value from the first grid and then on button click i am filling the other grid. any idea why i am not getting the second grid on the run time. as i can still both of the grids in design mode.

if you need i can post the coding also.

thanks & Regards

3 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 19 Jul 2011, 03:02 PM
Hello Mubasshar,

Most probably the binding for the second grid is not correct and the grid has no  records to display. We can tell you for sure when you post the actual code that you are using.

Best wishes,
Vasil
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
phani
Top achievements
Rank 1
answered on 17 May 2020, 06:14 PM

Hi Vasil

i have also problem.do i need two NeedDataSource events to bind the data.The first grid is binding data properly whereas second grid is not binding even though using second NeedDataSource event.Please help me

Thanks

Phani

<div class="container-fluid">
        <div class="row">
            <div class="col-sm-12 col-md-12">
                <telerik:RadAjaxPanel ID="RadAjaxPanel1" ClientEvents-OnRequestStart="onRequestStart" runat="server" CssClass="grid_wrapper" HorizontalAlign="NotSet">
                    <telerik:RadGrid ID="AvailableUsersGrid" OnNeedDataSource="AvailableUsersGrid_NeedDataSource" runat="server" PagerStyle-PageButtonCount="5" Skin="Vista"
                        AllowPaging="True" AllowSorting="True" OnPageIndexChanged="AvailableUsersGrid_PageIndexChanged" OnInit="AvailableUsersGrid_Init" OnItemCommand="AvailableUsersGrid_ItemCommand" OnPreRender="AvailableUsersGrid_PreRender" RenderMode="Auto" AutoGenerateColumns="False" Style="margin-top: 5px">
                        <GroupingSettings ShowUnGroupButton="true" />
                        <SortingSettings SortedBackColor="Fuchsia" />
                        <ExportSettings ExportOnlyData="true" IgnorePaging="true"></ExportSettings>
                        <MasterTableView
                            AllowFilteringByColumn="true" TableLayout="Auto"
                            CommandItemDisplay="Top" Font-Bold="true" Font-Size="Small"
                            InsertItemPageIndexAction="ShowItemOnFirstPage" DataKeyNames="USER_ID" CommandItemSettings-ShowExportToExcelButton="true" CommandItemSettings-ShowExportToCsvButton="true" CommandItemSettings-ShowRefreshButton="true" CommandItemSettings-ShowAddNewRecordButton="false">
                            <Columns>
                                <telerik:GridTemplateColumn AllowFiltering="false">
                                    <HeaderStyle Width="50px" />
                                    <ItemTemplate>
                                        <%--<telerik:RadCheckBox ID="checkboxselect" runat="server" AutoPostBack="false"></telerik:RadCheckBox>--%>
                                        <asp:CheckBox ID="checkboxselect"  runat="server" />
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn DataField="USER_ID" HeaderText="EMP CODE" FilterControlWidth="100px" SortExpression="USER_ID" AllowFiltering="true"
                                    UniqueName="USER_ID" AllowSorting="true" FooterText="USER_ID ">
                                    <HeaderStyle Width="150px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="EMAIL_ID" HeaderText="EMAIL ID" SortExpression="EMAIL_ID" AllowFiltering="true"
                                    UniqueName="EMAIL_ID" AllowSorting="true" FooterText="EMAIL_ID " FilterControlWidth="300px">
                                    <HeaderStyle Width="350px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="NAME" HeaderText="NAME" SortExpression="NAME" FilterControlWidth="300px" AllowFiltering="true"
                                    UniqueName="NAME" AllowSorting="true" FooterText="NAME">
                                    <HeaderStyle Width="350px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="FACILITY" HeaderText="FACILITY" SortExpression="FACILITY" AllowFiltering="true"
                                    UniqueName="FACILITY" AllowSorting="true" FooterText="FACILITY" FilterControlWidth="100px">
                                    <HeaderStyle Width="150px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ROLE" HeaderText="ROLE" SortExpression="ROLE" AllowFiltering="false"
                                    UniqueName="ROLE" AllowSorting="true" FooterText="ROLE" FilterControlWidth="150px">
                                    <HeaderStyle Width="150px" />
                                </telerik:GridBoundColumn>
                            </Columns>
                            <PagerStyle BackColor="#404040" BorderColor="#404040" />
                        </MasterTableView>
                        <ClientSettings AllowColumnsReorder="true" AllowColumnHide="true" AllowDragToGroup="true">
                            <Selecting AllowRowSelect="true" />
                            <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                        </ClientSettings>
                        <PagerStyle PageButtonCount="5" />
                        <FilterMenu RenderMode="Auto">
                        </FilterMenu>
                        <HeaderContextMenu RenderMode="Auto">
                        </HeaderContextMenu>
                    </telerik:RadGrid>
                </telerik:RadAjaxPanel>
            </div>
        </div>
        <div class="row" style="margin-top: 20px">
            <div class="form-group">
                <div class="row">
                    <div class="col-sm-12 text-center">
                        <telerik:RadButton ID="btnTestAssign" runat="server" Text="Assign Test" OnClick="btnTestAssign_Click1" CssClass="rbPrimaryButton" Skin="Silk"></telerik:RadButton>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group" style="margin-top: 1%">
            <div class="row">
                <div class="col-sm-12 text-center">
                    <telerik:RadLabel runat="server" Text="Test Assigned Users" Font-Bold="true" Font-Size="Large" RenderMode="Lightweight" Font-Underline="true"></telerik:RadLabel>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12 col-md-12">
                <telerik:RadAjaxPanel ID="RadAjaxPanel2" ClientEvents-OnRequestStart="onRequestStart" runat="server" CssClass="grid_wrapper" HorizontalAlign="NotSet">
                    <telerik:RadGrid ID="TestAssignedGrid" runat="server" PagerStyle-PageButtonCount="5" Skin="Vista"
                        AllowPaging="True" AllowSorting="True" OnNeedDataSource="TestAssignedGrid_NeedDataSource"  OnItemCommand="TestAssignedGrid_ItemCommand" OnItemCreated="TestAssignedGrid_ItemCreated" RenderMode="Auto" AutoGenerateColumns="False" Style="margin-top: 5px" OnInit="TestAssignedGrid_Init">
                        <GroupingSettings ShowUnGroupButton="true" />
                        <SortingSettings SortedBackColor="Fuchsia" />
                        <ExportSettings ExportOnlyData="true" IgnorePaging="false"></ExportSettings>
                        <MasterTableView
                            AllowFilteringByColumn="true" TableLayout="Auto"
                            DataKeyNames="SCHEDULE_END,TEST_ASSIGN_ID" CommandItemDisplay="Top" Font-Bold="true" Font-Size="Small"
                            InsertItemPageIndexAction="ShowItemOnFirstPage" CommandItemSettings-ShowExportToExcelButton="true" CommandItemSettings-ShowExportToCsvButton="true" CommandItemSettings-ShowRefreshButton="true" CommandItemSettings-ShowAddNewRecordButton="false">
                            <Columns>
                                <telerik:GridTemplateColumn AllowFiltering="false">
                                    <HeaderStyle Width="100px" />
                                    <ItemTemplate>
                                        <asp:LinkButton runat="server" ID="lnkbtn" Text="Delete" OnClick="lnkbtn_Click"  OnClientClick="openWinContentTemplate(); return false;"></asp:LinkButton>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridBoundColumn DataField="TEST_ASSIGN_ID" Display="false" SortExpression="TEST_ASSIGN_ID" AllowFiltering="false"
                                    UniqueName="TEST_ASSIGN_ID">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="TEST_NAME" HeaderText="TEST NAME" SortExpression="TEST_ID" AllowFiltering="true"
                                    UniqueName="TEST_ID" AllowSorting="true" FilterControlWidth="200px" FooterText="TEST_ID ">
                                    <HeaderStyle Width="250px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="USER_ID" HeaderText="USER ID" SortExpression="USER_ID" AllowFiltering="true"
                                    UniqueName="USER_ID" AllowSorting="true" FilterControlWidth="100px" FooterText="USER_ID ">
                                    <HeaderStyle Width="150px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ASSIGN_DATE" HeaderText="ASSIGN DATE" SortExpression="ASSIGN_DATE" AllowFiltering="false"
                                    UniqueName="SURVEY_ASSIGNED_DATE" AllowSorting="true">
                                    <HeaderStyle Width="200px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="SCHEDULE_START" HeaderText="SCHEDULE START" SortExpression="SCHEDULE_START" AllowFiltering="false"
                                    UniqueName="SCHEDULE_START" AllowSorting="true">
                                    <HeaderStyle Width="250px" />
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="SCHEDULE_END" HeaderText="SCHEDULE END" SortExpression="SCHEDULE_END" AllowFiltering="false"
                                    UniqueName="SCHEDULE_END" AllowSorting="true">
                                    <HeaderStyle Width="250px" />
                                </telerik:GridBoundColumn>
                            </Columns>
                            <PagerStyle BackColor="#404040" BorderColor="#404040" />
                        </MasterTableView>
                        <ClientSettings AllowColumnsReorder="true" AllowColumnHide="true" AllowDragToGroup="true">
                            <Selecting AllowRowSelect="true" />
                            <Scrolling AllowScroll="true" UseStaticHeaders="true" />
                        </ClientSettings>
                        <PagerStyle PageButtonCount="5" />
                        <FilterMenu RenderMode="Lightweight">
                        </FilterMenu>
                        <HeaderContextMenu RenderMode="Auto">
                        </HeaderContextMenu>
                    </telerik:RadGrid>
                </telerik:RadAjaxPanel>
            </div>
        </div>

 

    Protected Sub AvailableUsersGrid_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs)
        Dim dt As DataTable = New DataTable
        If oConn.State = ConnectionState.Closed Then
            oConn.ConnectionString = sConn
            oConn.Open()
        End If
        TestTitle = ddlTestTitle.SelectedValue
        If TestTitle <> "" Then
            strtDate = radstartdate.SelectedDate
            endDate = radenddate.SelectedDate
            CheckAssignedTest(strtDate, endDate)
        Else
            Try
                Dim da As OleDbDataAdapter = New OleDbDataAdapter("select USER_ID,EMAIL_ID,NAME,FACILITY.FACILITY_NAME as FACILITY,ROLES.ROLE_DETAILS as ROLE from USER_DETAILS,ROLES,FACILITY where user_details.facility  = facility.facility_id and user_details.role = roles.role_id", oConn)
                da.Fill(dt)
                AvailableUsersGrid.DataSource = dt
                If oConn.State = ConnectionState.Open Then
                    oConn.Close()
                End If
                oConn.Dispose()
            Catch ex As Exception
                Dim ss As String = ex.Message
            End Try
            dt.Dispose()
            oConn.Dispose()
        End If
    End Sub

 

 

 Protected Sub TestAssignedGrid_NeedDataSource(sender As Object, e As GridNeedDataSourceEventArgs)

        Dim dt1 As DataTable = New DataTable
        If oConn.State = Data.ConnectionState.Closed Then
            oConn.ConnectionString = sConn
            oConn.Open()
        End If
        Dim DataAdapter1 As OleDbDataAdapter = New OleDbDataAdapter("select TEST_ASSIGN_ID, TEST_SUITES.TEST_NAME as TEST_NAME,USER_ID,ASSIGN_DATE,SCHEDULE_START,SCHEDULE_END from TEST_SUITES_ASSIGNED,TEST_SUITES where TEST_SUITES_ASSIGNED.TEST_ID = TEST_SUITES.TEST_ID", oConn)
        Try
            DataAdapter1.Fill(dt1)
            TestAssignedGrid.DataSource = dt1

        Catch ex As Exception
            Dim ss As String = ex.Message
        End Try
        dt1.Clear()
        dt1.Dispose()
        oConn.Dispose()

    End Sub

0
Doncho
Telerik team
answered on 20 May 2020, 04:25 PM

Hi Phani,

Thank you for the code provided!

In general, each Radgrid needs a DataSource to have data to populate and process further. DataSource can be assigned in the OnNeedDataSource event or also in the markup if a DataSource component is used, see How to bind RadGrid properly on server-side

I couldn't find any obvious reason for the described behavior so I would suggest you following steps to narrow down the issue:

  • Ensure the DataTables assigned as data sources to both RadGrid(s) contain entries retuned from the database queries.
  • Make sure you are not calling DataBind() method anywhere in the page, see Programmatic Data Binding Using the NeedDataSource Event
  • Ensure the AJAX is properly implemented and you are not having any nested Ajaxified controls on the page, see Understanding AJAX Controls
  • Check for JavaScript errors on the Browsers' Developer Tools Console. If there are such, make sure to eliminate them as they will prevent the execution of further JavaScript and that could cause unexpected behavior of the controls.
  • Temporarily disable AJAX on the page as it may "hide" some server errors as JavaScript errors. Test the application while monitoring for JavaScript errors again, see Get more descriptive errors by disabling AJAX

If suggests steps are not helping in troubleshooting the case I would need more information to help further. Please provide the whole markup and code-behind of the page containing the RadGrid controls so that I have a more complete overview.

Looking forward to your feedback!

Kind regards,
Doncho
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Grid
Asked by
Mubasshar
Top achievements
Rank 1
Answers by
Vasil
Telerik team
phani
Top achievements
Rank 1
Doncho
Telerik team
Share this question
or