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

Paging Problem of RadListview Inside RadGrid

0 Answers 93 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Vempalli
Top achievements
Rank 1
Vempalli asked on 26 Dec 2012, 05:32 AM
Hi,
When i Put the RadListView inside RadGrid Binding is fine But when click the Next Page of RadListView it Showing
"Index was out of range. Must be non-negative and less than the size of the collection"
Paging is Implementd in RadListView, when go to next Page it showing the above error.......
my code is Like this
<telerik:RadListView ID="RadListViewAdBookings" runat="server"
        SkinID="WebBlue" DataKeyNames="BID" AllowPaging="true" PageSize="3"
            ItemPlaceholderID="BranchPalceHolder"
            onitemdatabound="RadListViewAdBookings_ItemDataBound"
            onneeddatasource="RadListViewAdBookings_NeedDataSource">
        <LayoutTemplate>
            <asp:PlaceHolder ID="BranchPalceHolder" runat="server"></asp:PlaceHolder>
            <div style="clear: both;">
            </div>
            <div style="background-color: #EBEBEB; height: 30px;">
                <div style="float: left; margin-left: 30%; text-align: center; margin-top: 5px;">
              <asp:LinkButton ID="btnFirst" runat="server" CommandName="Page" CommandArgument="First"
                        Text="First" Enabled="<%#Container.CurrentPageIndex > 0 %>" Font-Underline="false"
                        Style="font-family: calibri; font-size: 15px; font-weight: bold; color: #5FA3E1;
                        padding-left: 10px; padding-right: 10px;"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="btnPrev" runat="server" CommandName="Page" CommandArgument="Prev"
                        Text="Prev" Enabled="<%#Container.CurrentPageIndex > 0 %>" Font-Underline="false"
                        Style="font-family: calibri; font-size: 15px; font-weight: bold; color: #5FA3E1;
                        padding-left: 10px; padding-right: 10px;"></asp:LinkButton>
                    <span style="font-family: calibri; font-size: 15px; font-weight: bold; color: #545454;
                        padding-left: 10px; padding-right: 10px;">Page
                        <%#Container.CurrentPageIndex + 1 %>
                        of
                        <%#Container.PageCount %></span>
                    <asp:LinkButton ID="btnNext" runat="server" CommandName="Page" CommandArgument="Next"
                        Text="Next" Enabled="<%#Container.CurrentPageIndex + 1 < Container.PageCount %>"
                        Font-Underline="false" Style="font-family: calibri; font-size: 15px; font-weight: bold;
                        color: #5FA3E1; padding-left: 10px; padding-right: 10px;"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="btnLast" runat="server" CommandName="Page" CommandArgument="Last"
                        Text="Last" Enabled="<%#Container.CurrentPageIndex + 1 < Container.PageCount %>"
                        Font-Underline="false" Style="font-family: calibri; font-size: 15px; font-weight: bold;
                        color: #5FA3E1; padding-left: 10px; padding-right: 10px;"></asp:LinkButton>
                    <span style="font-family: calibri; font-size: 15px; font-weight: bold; color: #545454;
                        padding-left: 10px;">Page Size:</span>
                    <telerik:RadComboBox runat="server" ID="cmbPageSize" OnSelectedIndexChanged="cmbPageSize_SelectedIndexChanged"
                        AutoPostBack="true" Width="40px" SelectedValue="<%#Container.PageSize %>">
                        <Items>
                            <telerik:RadComboBoxItem Text="3" Value="3"></telerik:RadComboBoxItem>
                            <telerik:RadComboBoxItem Text="6" Value="6"></telerik:RadComboBoxItem>
                            <telerik:RadComboBoxItem Text="9" Value="9"></telerik:RadComboBoxItem>
                            <telerik:RadComboBoxItem Text="12" Value="12"></telerik:RadComboBoxItem>
                        </Items>
                    </telerik:RadComboBox>
                    
                </div>
            </div>
        </LayoutTemplate>
        <ItemTemplate>
            <div class="in-searches">
            <div class="in-branch-info">
                <table width="100%" cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td>
                              <div class="branch">
                                <asp:Label ID="lblBranchID" runat="server" Visible="false" Text='<%#Eval("BID") %>'></asp:Label>
                                    <%#Eval("BranchName")%></div>
                                <div class="dis">
                                    <strong>
                                        <%#Eval("Address")%><br />
                                        Queue : 15<br />
                                    </strong><span><strong>Next available Time : 4pm</strong></span>
                                </div>
                           
                        </td>
                        
                    </tr>
                   <tr>
                        <td valign="top">
                        <div class="dis"><strong>Available Slots</strong>
                         <telerik:RadGrid ID="RadGridDates" Width="100%" runat="server"  ShowHeader="false"
                        GridLines="None" AutoGenerateColumns="false" OnNeedDataSource="RadGridDates_NeedDataSource">
                        <MasterTableView AutoGenerateColumns="false" >            
                       <Columns>
                       <telerik:GridTemplateColumn ItemStyle-CssClass="date">
                       <ItemTemplate>
                       <%#Eval("BookingDate")%>
                       </ItemTemplate>
                       </telerik:GridTemplateColumn>
                         <telerik:GridTemplateColumn ItemStyle-CssClass="count">
                       <ItemTemplate>
                       <%#Eval("Bookingcount")%>
                       </ItemTemplate>
                       </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn ItemStyle-CssClass="book">
                       <ItemTemplate>
                        1
                       </ItemTemplate>
                       </telerik:GridTemplateColumn>
                       </Columns>
                        </MasterTableView>
                        </telerik:RadGrid>
                        </td>
                         </div>
                    </tr>
                </table>
            </div>
            </div>
        </ItemTemplate>
    </telerik:RadListView>

in Code Behind

 DataTable dtList = new DataTable();
    DataSet dsList = new DataSet();
    SqlParameter [] objSqlParameter;

    VQBranchesBC objVQBranchesBC = new VQBranchesBC();
    VQBranchesInterfaceReq objVQBranchesInterfaceReq = new VQBranchesInterfaceReq();
    VQBranchesInterfaceResp objVQBranchesInterfaceResp = new VQBranchesInterfaceResp();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            
        }
    }
    protected void cmbPageSize_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        RadListViewAdBookings.PageSize = int.Parse(e.Value);
        RadListViewAdBookings.CurrentPageIndex = 0;
        RadListViewAdBookings.Rebind();
    }
    protected void RadListViewAdBookings_ItemDataBound(object sender, RadListViewItemEventArgs e)
    {
        if (e.Item is Telerik.Web.UI.RadListViewDataItem)
        {
            DataList DataListDates = (DataList)e.Item.FindControl("DataListDates");
            Label lblBranchID = (Label)e.Item.FindControl("lblBranchID");
        }
    }


    protected void RadListViewAdBookings_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
    {
        objVQBranchesInterfaceReq.Activity = "SELECT";
        objVQBranchesInterfaceReq.Status = true;
        objVQBranchesInterfaceReq.IsDelete = false;
        objVQBranchesInterfaceResp = objVQBranchesBC.VQBranchesList(objVQBranchesInterfaceReq);
        dtList = objVQBranchesInterfaceResp.Records;
        RadListViewAdBookings.DataSource = dtList;
    }
  protected void RadGridDates_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {

        var grid = sender as RadGrid;
        var lvItem = grid.NamingContainer as RadListViewDataItem;
        var data = Convert.ToInt32(lvItem.GetDataKeyValue("BID"));
        objSqlParameter = new SqlParameter[3];
        string strDate = GlobalFunctions.GetCountryDateTime().ToString("MM/dd/yyyy");
        objSqlParameter[0] = new SqlParameter("@Today", strDate);
        objSqlParameter[1] = new SqlParameter("@intFlag", "-10");
        objSqlParameter[2] = new SqlParameter("@BranchID", data);
        dsList = VQ.VQDBFunctions.ExecuteDataSetWithParams(CommandType.StoredProcedure, "SP_VQ_GetAdvanced_BookingInfo_Slots", objSqlParameter);
        grid.DataSource = dsList;
        RadListViewAdBookings.AllowPaging = true;
       
    }


No answers yet. Maybe you can help?

Tags
ListView
Asked by
Vempalli
Top achievements
Rank 1
Share this question
or