Do not recognize an expression in code

Hi,

I am testing the code on page 553 of book “Build your own website in asp.net 4 using C# and vb”. I could not understand the following expression,

if (sortExpression == gridSortExpression)

Where “gridSortExpression” is defined?

I am using visual studio express 2012 and not able to execute the code on page 553 and 554. I will appreciate immediate help.

On page 553 (maybe 554), there is the following:

Private Property gridSortExpression() As String
  Get
    If (ViewState("GridSortExpression") Is Nothing) Then
      ViewState("GridSortExpression") = "DepartmentID"
    End If
    Return ViewState("GridSortExpression")
  End Get
  Set(ByVal value As String)
    ViewState("GridSortExpression") = value
  End Set
End Property

[highlight=C#]private string gridSortExpression
{
get
{
if (ViewState[“GridSortExpression”] == null)
{
ViewState[“GridSortExpression”] = “DepartmentID”;
}
return (string) ViewState[“GridSortExpression”];
}
set
{
ViewState[“GridSortExpression”] = value;
}
}

If you ever want to find a variable and you are using visual studio, you can usually right click on it and choose “go to declaration” to figure out where it is declared.

That only helps if you have declared it :slight_smile: In his case, he hadn’t done that yet, as he missed that part of the code :smiley: