开发者

Expression Expected

开发者 https://www.devze.com 2022-12-21 01:25 出处:网络
Im getting a build error with the following code... Private Property GridViewSortDirection() As String

Im getting a build error with the following code...

Private Property GridViewSortDirection() As String

    Get
        Return If(TryCast(ViewState("SortDirection"), String), "ASC")
    End Get
    Set(ByVal value As String)
        ViewState("SortDirection") = value
    End Set

End Property

It is happening on the following line...

Return If(TryCast(ViewState("开发者_开发问答SortDirection"), String), "ASC")

Error returns...

Error 11 C:\inetpub\wwwroot\TPSupport\main\UserControls\grid.ascx.vb(192): error BC30201: Expression expected.

Any Idea's

Thanks

Its a convert from c#

private string GridViewSortDirection
{
   get { return ViewState["SortDirection"] as string ?? "ASC"; }
   set { ViewState["SortDirection"] = value; }
}


I am not familiar with VB but use of If keyword shows that you are doing comparison between result of TryCast and "ASC",

Try this way, by using appropriate comparison operator like

 Return If(TryCast(ViewState("SortDirection"), String) <> "ASC")


What compiler version are you using? I suspect that you inadvertently switched to a version of VB (< 9.0) that doesn’t yet support the conditional operator.

0

精彩评论

暂无评论...
验证码 换一张
取 消