模板字段和href属性? [英] Template field and href attribute ?
本文介绍了模板字段和href属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下asp鳕鱼:
I have the following asp cod:
<asp:Repeater ID="rpt1" runat="server" onitemdatabound="rpt1_ItemDataBound">
<ItemTemplate>
<div style="float:left; padding-removed4px"><%# Eval("Name") %> </div>
<div style="float:left; padding-removed4px"><%# Eval("CollectionType")%></div>
<div style="float:right">
<a href="AddItem.aspx?c=<%# Eval("CollectionID") %>">[edit item]</a>
</div>
<br />
</ItemTemplate>
</asp:Repeater>
您能解释一下该asp行中发生了什么吗?
Can you explain please what is occurring in this asp row?
<a href="AddItem.aspx?c=<%# Eval("CollectionID") %>">[edit item]</a>
预先谢谢您.
Thank you in advance.
推荐答案
在上面您已经创建了AddItem.aspx的链接.
在?"之后,您已定义了一个参数.在这种情况下,您有一个参数"c".
要设置参数,请在c后面加上"=".
最后,您通过调用<%Eval("CollectionID")%>从数据源设置了参数"c".
如果您在传递参数值时遇到问题,请尝试将左引号和右引号改为单引号.
< a href ="AddItem.aspx?c =<%Eval(" CollectionID)%>"> </a>至:
< a href =''AddItem.aspx?c =<%Eval("CollectionID")%>''> </a>
现在,只要您单击行中的链接,它就会将您重定向到AddItem.aspx并通过CollectionID参数.
这有用吗?
Above you have created a link to AddItem.aspx.
After the ''?'' you have defined a parameter. In this case you have a parameter ''c''.
To set the parameter you follow the c with ''=''.
Finally you have set the parameter ''c'' from the datasource by calling <% Eval("CollectionID") %>.
If you are having problems with this passing the parameter value try changing the opening and closing double quotes to single quotes.
<a href="AddItem.aspx?c=<% Eval("CollectionID") %>">[edit item]</a> to:
<a href=''AddItem.aspx?c=<% Eval("CollectionID") %>''>[edit item]</a>
Now anytime you click the link in the row it will redirect you to AddItem.aspx and also pass through the CollectionID parameter.
Is this helpful?
这篇关于模板字段和href属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文