1. 程式人生 > >HyperLink 傳引數要使傳遞的引數為字串

HyperLink 傳引數要使傳遞的引數為字串


傳1個引數

方法1:



<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# String.Format("~/practice/cookie2.aspx?id={0}", Eval("id"))
%>'>inid</asp:HyperLink>

方法2:

<asp:HyperLink id="Hyperlink1" NavigateUrl='<%# string.Format("List.aspx?Id={0}",DataBinder.Eval(Container.DataItem,"ID"))%>' runat="server">檢視</asp:HyperLink>

方法3:

<asp:HyperLink id=Hyperlink2 NavigateUrl= ' <%# "Detail.aspx?Code= "+DataBinder.Eval(Container.DataItem, "N_ID ")%> ' text= ' <%# DataBinder.Eval(Container.DataItem, "N_title ") %> ' Runat= "server ">

asp:HyperLink ID= "NewsTitle1 " Text= ' <%# Left(CType(DataBinder.Eval(Container.DataItem, "Title "),String),20)+ "... "%> ' NavigateUrl= ' <%# "newsDetail.aspx?id= "+DataBinder.Eval(Container.DataItem, "id ").ToString() %> ' Target=_blank Runat=server />

傳遞多個引數

方法1:

   <asp:HyperLink ID="statedm" runat="server"
NavigateUrl='<%# "UserManger.aspx?udid="+DataBinder.Eval(Container.DataItem,"Udid").ToString()+"&udid="+DataBinder.Eval(Container.DataItem,"State").ToString()%>'></asp:HyperLink>

方法2:

<asp:HyperLink id=Hyperlink2 runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Pro_name"," {0}") %>' NavigateUrl='<%#DataBinder.Eval(Container.DataItem, "pro_id","product.aspx?id={0}")+ "&pro_type="+DataBinder.Eval(Container, "DataItem.Pro_type")%>'>