English 中文(简体)
如何从数据来源向<a> tag提问?
原标题:how to set query string from the datasource to the <a> tag?

I m 采用从Ap.net对具有约束力的数据来源的重复控制。 我增加了标语作为模板项目。 我想从我的桌子到左上方的胸部。 在设计中如何做到这一点?

感谢

最佳回答

您在此有两种办法,首先直接放在项目模板中。

<ItemTemplate>
    <a href="/Folder/Item.aspx?ID=<%# Eval("KeyField") %>">Text</a>
</ItemTemplate>

或使用超文本链接

<ItemTemplate>
    <asp:HyperLink ID="myLink" runat="server" Text="Text" />
</ItemTemplate>

并且,你还应在<代码>上的逻辑上添加一些代码。 项目DataBound 重复活动

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {
    var myLink = e.Item.FindControl("myLink") as HyperLink;
    myLink.NavigateUrl = String.Format("~/Folder/Item.aspx?ID={0}", (e.Item.DataItem as YourType).KeyField);
}

数据项目是代表数据来源的单一项目。 如果您使用<代码>可测量,则最有可能是数据Row。 它也可以是习俗物或匿名。 这里我假定,你有一个标有<代码>YourType的标有<代码>Key Field。

问题回答

暂无回答




相关问题
How can I make a query string tamper-proof?

I need to use query strings in a URL, but need to ensure that they haven t been tampered with. I found a solution which almost works, but the encoded strings get mangled by a service my app needs to ...

Passing Lists as a QueryString - should I use JSON

Lets say I ve got an online dating site, users can filter the user list based on various criteria, Height, Age, BodyType, Ethnic Origin.... I want to pass the criteria to the pager, via QueryString. ...

Is using URL query string variables still RESTful

I m presented with a problem of using query string variables in a RESTful Asp.net MVC application. Does that violate the RESTful pattern? The thing is that Asp.net MVC uses default route like: /...

URL requests adding POST data to querystring

I am using ExtJS to send an Ajax request to a PHP page on a server, wanting to send the parameters as POST variables rather than in the querystring. I have included a random token in the querystring ...

Maintain the querystring in all pages in mvc

I need to maintain the querystring in all pages in my asp.net mvc(C#) application. For ex.: I will call a page www.example.com?Preview=True. The querystring should be maintained whatever the page i ...

Nginx 301 redirect inc. set cookie

what I m looking for is the ability for nginx to detect that a url has the query string variable cid. for example www.adomain.com/froggy?cid=12&as=false (query string can be solo or mixed with ...

ASP.NET: URI handling

I m writing a method which, let s say, given 1 and hello should return http://something.com/?something=1&hello=en. I could hack this together pretty easily, but what abstraction functionality ...

Checking querystring values in PHP

http://localhost/?area=characters&name=Michal+Stroganof $result = mysql_query("SELECT * from players WHERE name = $_GET[name] "); while ($row = mysql_fetch_assoc($result)) { echo "Name: " ....

热门标签