protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        DataContext db = new DataContext();
        using (var SI = new DataContext())
        {
            var search = (from l in SI.****
                          orderby l.*** descending
                          where l.**** == l.****
                          select l).First();
            Session["ID"] = search.***;
            Response.Redirect("http://localhost:63558/****.aspx");
        }
    }

So here I have it so when I hit "Edit" on the gridview it takes me to a new page. I want to be able to grab an ID from that row and save as session.

Say the person has an ID of 3 I click edit on him and then it shows 3 as the ID. But right now it only shows since it's in descending shows last person even if I click on the first person.

If any of this makes any sense. Want to look at that column and that row after I hit edit and save that ID as session.

Any help would be awesome thanks.

Hi,

I would suggest if you could check your "where" clause as sometimes it may be giving you the last element as you are saying. May be that wwould helo and more over you have starred the items contained in that particular attribute and its hard to sya which part would be inappropriate.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.