How to replace a codebehind method with an aspx method using ternary operator
<p>I have an asp:hyperlink control as part of a gridview template. The code in the aspx page is given below:</p>

<pre><code>asp:HyperLink runat="server" ID="lnkEdit" ToolTip="Edit article" NavigateUrl='&lt;%# GetUrl(Eval("ID").ToString(), Eval("CategoryID").ToString()) %&gt;' ImageUrl="~/Images/Edit.gif"
</code></pre>

<p>The NavigateUrl value is obtained from the codebehind method GetUrl(string, string). The code works fine and is as follows:</p>

<pre><code>protected string GetUrl(string id, string categoryID)
{
    var CategoryID = string.Empty;
    if (!String.IsNullOrEmpty(Request.QueryString["CatID"]))
    {
        CategoryID = Request.QueryString["CatID"].ToString();
    }
    else if (!String.IsNullOrEmpty(categoryID))
    {
        CategoryID = categoryID;
    }
    return "~/TBSArticles/WriteOrEditArticle.aspx?ID=" + id + "&amp;CatID=" + CategoryID;
}
</code></pre>

<p>I want to replace the code behind method by using a ternary operator within the aspx page. I tried something like below, but didn't work:</p>

<pre><code>asp:HyperLink runat="server" ID="lnkEdit" ToolTip="Edit article" NavigateUrl='&lt;%# "~/TBSArticles/WriteOrEditArticle.aspx?ID=" + Eval("ID")  + "&amp;CatID=" + Eval(this.Request.QueryString["CatID"].ToString()) != ""? this.Request.QueryString["CatID"] : Eval("CategoryID")) %&gt;' ImageUrl="~/Images/Edit.gif"
</code></pre>
