Danish woman 0 Newbie Poster

I have a forum where the threads are showing in a datagrid with paging. The paging works fine and show the right result on the next pages.
My problem is in the column which contains a link to the page where the client can read the thread. The link includes the datakey, but the datakey is showing the keys from the first page.

This is the column:

<asp:Templatecolumn ItemStyle-Width="356" ItemStyle-CssClass="bg_forumTema" >
          <itemtemplate>
          <asp:linkbutton ID="lbTema" runat="server" CssClass="formal_blue_bold" CommandName="Select"
             Text='<%#Container.DataItem("tema")%>' />
     </itemtemplate>
    </asp:templatecolumn>

The datagrid contains this line:

OnSelectedIndexChanged="vis_indlaeg"

Here is the sub where the site is redirected to the wrong post:

Sub vis_indlaeg(obj as object, e as EventArgs)
    response.Redirect("forum_vis_indlaeg.aspx?id=" & Datagrid1.DataKeys(Datagrid1.SelectedIndex))
end sub

Viewstate is disabled

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.