SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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.

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,169
    Mentioned
    153 Post(s)
    Tagged
    0 Thread(s)
    On page 553 (maybe 554), there is the following:
    Code VB:
    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

    Code C#:
    private string gridSortExpression
    {
      get
      {
        if (ViewState["GridSortExpression"] == null)
        {
          ViewState["GridSortExpression"] = "DepartmentID";
        }
        return (string) ViewState["GridSortExpression"];
      }
      set
      {
        ViewState["GridSortExpression"] = value;
      }
    }

  3. #3
    SitePoint Member
    Join Date
    Mar 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks I really appreciate it. I think I was too focused finding the variable!

    Quote Originally Posted by cpradio View Post
    On page 553 (maybe 554), there is the following:
    Code VB:
    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

    Code C#:
    private string gridSortExpression
    {
      get
      {
        if (ViewState["GridSortExpression"] == null)
        {
          ViewState["GridSortExpression"] = "DepartmentID";
        }
        return (string) ViewState["GridSortExpression"];
      }
      set
      {
        ViewState["GridSortExpression"] = value;
      }
    }

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,638
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,169
    Mentioned
    153 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by wwb_99 View Post
    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 In his case, he hadn't done that yet, as he missed that part of the code


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •