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.
精彩评论