viewstate lost when using querystring

Discussion in 'ASP .Net' started by Max, Feb 26, 2004.

  1. Max

    Max Guest

    Is there anyway to preserve the current viewstate when a hyperlink is
    clicked to the same page? I have a datagrid on "customers.aspx" but I want
    to have several hyperlinks that do not post, they just querystring like
    "customers.aspx?id=56" but once this happens, all the viewstate is lost or
    reset.

    -Max
    Max, Feb 26, 2004
    #1
    1. Advertising

  2. If you have arguments (id=56) to be processed on the server side, and you
    want the state preserved, you need a postback

    Instead of using a regular Hyperlink control, use a LinkButton (same user
    interface) and assign the arguments in its CommandArgument property.

    On the click event of the LinkButton, you get the submitted argument as
    follows:

    string myArgs = ((LinkButton)sender).CommandArgument // C#
    syntax

    Dim myArgs as String = CType(sender, LinkButton).CommandArgument
    ' VB.NET Syntax
    Regards

    Jose


    "Max" <> escribió en el mensaje
    news:Zdl%b.139812$...
    > Is there anyway to preserve the current viewstate when a hyperlink is
    > clicked to the same page? I have a datagrid on "customers.aspx" but I want
    > to have several hyperlinks that do not post, they just querystring like
    > "customers.aspx?id=56" but once this happens, all the viewstate is lost

    or
    > reset.
    >
    > -Max
    >
    >
    >
    >
    Jose Marcenaro, Feb 26, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris  Ashley

    Querystring - persisting viewstate?

    Chris Ashley, Oct 12, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    2,283
    Chris Ashley
    Oct 12, 2005
  2. Mehdi
    Replies:
    6
    Views:
    36,041
    sloan
    Apr 6, 2006
  3. Froefel

    Querystring or ViewState question

    Froefel, Jul 19, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    356
    =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=
    Jul 19, 2007
  4. Froefel

    Querystring or ViewState question

    Froefel, Jul 19, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    306
    Froefel
    Jul 19, 2007
  5. Adeel Ahmad
    Replies:
    1
    Views:
    292
    Anthony Jones
    Mar 7, 2006
Loading...

Share This Page