[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Bob H

2/25/2004 12:00:00 PM

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


1 Answer

Bob H

2/25/2004 12:39:00 PM

0

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

bob

"Bob H" <bh15@le.ac.uk> wrote in message
news:c1i2ne$ov4$1@south.jnrs.ja.net...
> 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
>
>