Technique to navigate to specific row

4 posts, 0 answers
  1. Kermit
    Kermit avatar
    20 posts
    Member since:
    Jan 2012

    Posted 02 Jan 2013 Link to this post

    I have a radGrid with paging enabled (20 rows per page).  The grid could sometimes have 1500 rows in it.  The rows represent book titles with associated data like price, author, etc.  Could anyone suggest a technique or mechanism to allow the user to specify a book title and have the grid jump to the grid page that contains that title?

    I do not want to use filtering... I want the displayed grid to remain fully populated with all 1500 rows.

    Thanks.
  2. Kermit
    Kermit avatar
    20 posts
    Member since:
    Jan 2012

    Posted 04 Jan 2013 Link to this post

    No one else has ever had this requirement?  Anyone?  Hard to believe...
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 05 Jan 2013 Link to this post

    Hi,

    Here is the sample code that I tried to achieve your scenario.

    ASPX:
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Search" OnClick="Button1_Click" />
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" PageSize="5" AutoGenerateColumns="false" DataSourceID="SqlDataSource1">
      <MasterTableView>
         <Columns>
           <telerik:GridBoundColumn DataField="EmployeeID" HeaderText="EmployeeID" UniqueName="EmployeeID">
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="FirstName" HeaderText="First Name" UniqueName="FirstName">
           </telerik:GridBoundColumn>
           <telerik:GridBoundColumn DataField="LastName" HeaderText="Last Name" UniqueName="LastName">
           </telerik:GridBoundColumn>
       </Columns>
    </MasterTableView>
    </telerik:RadGrid>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT * FROM [Employees] " >
    </asp:SqlDataSource>

    C#:
    protected void Button1_Click(object sender, EventArgs e)
        {
            RadGrid1.AllowPaging = false;
            RadGrid1.Rebind();
            int rowIndex=0;
            foreach (GridDataItem item in RadGrid1.Items)
            {
                string strIndex = RadGrid1.MasterTableView.CurrentPageIndex.ToString();
                if (item["FirstName"].Text == TextBox1.Text)
                {
                     rowIndex = item.ItemIndex;
                     break;
                }
            }
            RadGrid1.AllowPaging = true;
            int pageSize = RadGrid1.MasterTableView.PageSize;
            int newPageIndex = rowIndex/ pageSize;
            RadGrid1.MasterTableView.CurrentPageIndex = newPageIndex;
            RadGrid1.Rebind();
        }

    Hope this helps.

    Regards,
    Princy.
  5. Kermit
    Kermit avatar
    20 posts
    Member since:
    Jan 2012

    Posted 08 Jan 2013 Link to this post

    Thank you Princy, I'll give that a shot when I get a free moment.  Appreciate your help!
Back to Top