viewstate lost when using querystring

  • Thread starter Thread starter Max
  • Start date Start date
M

Max

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
 
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
 
Back
Top