Get RadGrid Row Count and DataKey In PreRender

2 posts, 0 answers
  1. Perry
    Perry avatar
    57 posts
    Member since:
    Jul 2015

    Posted 17 Jan Link to this post

    I have a RadGrid with 700,000 rows.  I do not bind the RadGrid until the user runs a search function to filter the data.  If the filtered data returns only 1 row I would like to skip showing the the Radgrid and just open a web page that would show the information for the single record.  I can not figure out how to the get the DataKey for that single record.

    I am thinking the logical place would be the PreRender event.  to get a row count in the prerender and if that row count was 1 then get the datakey and redirect to my edit page with the the data key as my QueryString. 

    This is far as I can get with the code:

    int count = RadGrid1.Items.Count;
                if (count == 1)
                {
                    string a ="How can I get the datakey value for this 1 row ?"
                }
  2. Perry
    Perry avatar
    57 posts
    Member since:
    Jul 2015

    Posted 17 Jan in reply to Perry Link to this post

    I was able
    int count = RadGrid1.Items.Count;
                if (count == 1)
                {
                    string ID = RadGrid1.MasterTableView.Items[0].GetDataKeyValue("ID").ToString();
                    Response.Redirect("~\\Add-EditRecord.aspx?ID=" + ID, false);
                }
    to figure this out here is the code that works for me
Back to Top