DataGrid problem - help!

B

Bob H

Hi,

I'm new to ASP.Net and am having problems with clicking on a grid item and
being forwarded to another page. Can anyone help out please?

In my grid I've a template column to show a link comprised of several
columns of data (only 1 shown here). I've tried a couple of ways: First I've
tried using the OnCommand of the LinkButton and then I tried using the
OnItemCommand of the Datagrid to point to my ViewDetails sub in the code
behind file

<asp:datagrid...>
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton OnCommand="ViewDetails" Runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.Name")%>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>

Sub ViewDetails(ByVal sender As System.Object, ByVal e As CommandEventArgs)
Response.Redirect("viewdetails.aspx", False)
End Sub

Once the user clicks the link, I thought that the Viewdetails sub gets
called and they get forwarded to the viewdetails.aspx. This code only seems
to postback to the same page ie the ViewDetails sub doesn't seem to get
called (Once I've got this page working, the idea was to get the ID of the
row the user clicked on and post it with the form to the viewdetails.aspx)

Any clues/pointers please?

Cheers

Bob
 
B

Bob H

...should have set the EnableViewState for the datagrid to True and the
OnItemCommand event gets fired.

bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top