<asp:DataList ID="DataList1" runat="server" Width="612px">
    <ItemTemplate>
        <asp:Image ID="ImageFirst" runat="server"  ImageUrl="~/Images/BULLET.GIF" />
        <asp:HyperLink ID="HyperLinkFirst" runat="server" meta:resourcekey="??"
            NavigateUrl="~/Reports/CenterReport.aspx" Text="aa"></asp:HyperLink>
        <asp:LinkButton ID="LinkButtonFirst" runat="server"meta:resourcekey="??" PostBackUrl="???" asp:LinkButton>
    </ItemTemplate>
</asp:DataList>有问号的地方可以用<%# Bind("Name") %>这种来写,但是有的域除了从数据源拿来后还要考虑别的条件,如当Session["type"]为"p"时,meta:resourcekey = "public" + <%# Bind("id") %>,但这样写不对,该怎么写呢

解决方案 »

  1.   

    meta:resourcekey = "public" + <%# Bind("id") %>
    改为:
    meta:resourcekey = <%# "public" + Bind("id").ToString() %>
      

  2.   

    条件怎么写呢
    Session["type"]为"p"时,meta:resourcekey = "public" + <%# Bind("id") %>,
    Session["type"]为"s"时,meta:resourcekey = "personal" + <%# Bind("id") %>,
      

  3.   

    <%# Session["type"]="p"?Bind("Name"):"public" +Session["type"]为"p" %>
      

  4.   

    <%# Session["type"]=="p"?"public":"personal" + Bind("id").ToString() %>
      

  5.   

    放到<%# ... %>里面~
      

  6.   

    <%# if(Session["type"]=="p"){"public" + Bind("id");} if(Session["type"]=="s"){"personal" + Bind("id");} %>
      

  7.   

    <asp:DataList ID="DataList1" runat="server" Width="612px">
        <ItemTemplate>
            <asp:Image ID="ImageFirst" runat="server"  ImageUrl="~/Images/BULLET.GIF" />
            <asp:HyperLink ID="HyperLinkFirst" runat="server" meta:resourcekey="??"
                NavigateUrl="~/Reports/CenterReport.aspx" Text="aa"></asp:HyperLink>
            <asp:LinkButton ID="LinkButtonFirst" runat="server"meta:resourcekey="??" PostBackUrl='<%# myfunc(DataBinder.Eval(Container.DataItem,"Name)%> ' asp:LinkButton>
        </ItemTemplate>
    </asp:DataList>
    后台
    protected string myfunc(object s1)
    {
    string name=s1.ToString();
    //这里面,你想怎么写就怎么写。
    //
    return name;
    }
      

  8.   

    meta:resourcekey = <%# "public" + Bind("id").ToString() %>
      

  9.   

    daishengs(横舟摆渡) ( )
    的方法绝对可以实现你的功能
      

  10.   

    当然都放到<%# ... %>里面阿
      

  11.   

    meta:resourcekey 不能动态指定?Server tags cannot contain <% ... %> constructs.
    The server tag is not well formed.后来还是用了ItemDataBound事件,在这里就随你怎么写了:)
    resourcekey 是用下面的方法解决的
    HyperLink.Text = GetLocalResourceObject(myDataRowView.Row["key2"].ToString() + ".Text").ToString();