<asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.name", "../THGL_new.aspx?subTitle={0}&Title=") %>' Text='<%# DataBinder.Eval(Container, "DataItem.name") %>'>
里面的Title如果要获得后台的一个变量的值,应该怎么写?

解决方案 »

  1.   

    NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.name", "../THGL_new.aspx?subTitle={0}&Title=" + 变量名) %>'
    这样不行嘛?
      

  2.   

    The DataGrid's HyperLinkColumn column is great to have a column with an hyperlink that points to an Url with a parameter whose value is taken from the data source, but what if you need to build the target Url with more than one parameter taken from the data source? In this case you can use a template column as follows: <TemplateColumn>
        <ItemTemplate>
           <asp:HyperLink Runat="server" NavigateUrl='<%# "Details.aspx?EmployeeID=" & Container.DataItem("ID")&"&EmployeeName=" & Container.DataItem("FirstName")%>'/>
        </ItemTemplate>
    </TemplateColumn>Instead of doing the string concatenation yourself you can use the BuildUrlWithQueryString function, which must be declared with Public/Protected visibility in the code-behind, as follows: <TemplateColumn>
        <ItemTemplate>
          <asp:HyperLink Runat="server" NavigateUrl='<%# _
             BuildUrlWithQueryString("Details.aspx", "EmployeeID", Container.DataItem("ID"),"EmployeeName", Container.DataItem("FirstName")) %>' />
       </ItemTemplate>
    </TemplateColumn> http://java.mblogger.cn/brian_jin/posts/2792.aspx<asp:TemplateColumn HeaderText="购买">
    <ItemTemplate>
    <asp:HyperLink id=HyperLink1 runat="server" 
     Text='<%# DataBinder.Eval(Container, "DataItem.dinggou")%>' 
     NavigateUrl='<%# "../gouwu/gouwu_ls.aspx?commoditytype=" & 
      DataBinder.Eval(Container, "DataItem.commoditytype")
      & "&commodityname=" & DataBinder.Eval(Container, "DataItem.commodityname")%>' /> 
    </ItemTemplate>
    </asp:TemplateColumn>
      

  3.   

    在C#中:
    <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.name", "../THGL_new.aspx?subTitle={0}&Title="+变量名)%>' Text='<%# DataBinder.Eval(Container, "DataItem.name") %>'>
    在VB.NET中
    <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.name", "../THGL_new.aspx?subTitle={0}&Title="&变量名)%>' Text='<%# DataBinder.Eval(Container, "DataItem.name") %>'>
      

  4.   

    TO jxufewbt(我的目标是5星) :
    按这样写了以后:<asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.name", "../THGL_new.aspx?subTitle={0}&Title="+变量名)%>' Text='<%# DataBinder.Eval(Container, "DataItem.name") %>'>报错信息为:名称“strtitle”在类或命名空间“ASP.SubCategoryList_ascx”中不存在。
    .cs文件里面可以肯定strtitle已经赋值了。