如何在ASP.Net中创建动态链接 [英] How to create dyanamic links in ASP.Net
问题描述
嗨
我的方案就像我在数据库中有两张桌子
1.零售商列表
2. StoreList
在第一张表中,我列出了想参加我们活动的零售商名单
在第二张表中,我有这些零售商所拥有的商店。 br />
一个零售商可能有任意数量的商店。
我有一个Aspx页面我正在从第一个表格动态加载零售商列表我想当用户点击该零售商时,它应该重定向到另一个aspx页面,该页面将显示零售商拥有的所有商店,其中包含来自表2的常见信息。
我只能填充零售商列表,但后来的情况是看起来单调乏味。
谢谢
为什么呢?这很简单。看我的逻辑。Quote:我只能填充零售商列表,但后来的情况看起来很乏味。
建议逻辑
假设
StoreList 包含RetailerId
作为参考或外键
。
如果没有,那么你需要相应地修改逻辑。
逻辑
- 点击特定的零售商,只需将
ID
作为QueryString
到下一页(商店页面),比如...
var retailerId = yourRetailerId;
Response.Redirect( Stores.aspx?RetailerID = + HttpUtility.UrlEncode(retailerId ));
- 现在,在商店页面上,检索
QueryString
的值RetailerID
。- 查询到数据库表
StoreList
对于那个特定的零售商
喜欢...
SELECT Col1,Col2,Col3 FROM StoreList
WHERE
RetailerId = yourQueryStringRetailerId
注意
用实际替换Col1,Col2,Col3
列名。
在ADO.NET
对象的帮助下执行此查询并传递QueryString
正确指向查询。
Hi
My scenario is like I have two tables in database
1. RetailerList
2. StoreList
In first table I have a list of retailers who want to participate in our events
In second table I have stores that those retailers have.
One retailer may have any number of stores.
I have a Aspx page on which I am loading List of retailers dynamically from first table and I want when user click on that retailer, it should redirect to another aspx page which will show all store that retailer have with common info from table 2.
I can only populating Retailers list, but later scenario is looking tedious.
Thanks
Quote:I can only populating Retailers list, but later scenario is looking tedious.
Why? It's easy. See my Logic.
Proposed Logic
Assumption
StoreList containsRetailerId
as a Reference orForeign Key
.
If not, then you need to modify the logic accordingly.
Logic
- On Click of a particular Retailer, just pass his
ID
as aQueryString
to the Next Page (Stores Page) like...
var retailerId = "yourRetailerId"; Response.Redirect("Stores.aspx?RetailerID=" + HttpUtility.UrlEncode(retailerId));- Now, on the Stores Page, retrieve the
QueryString
value forRetailerID
.- Query to Database Table
StoreList
for that particularRetailer
like...
SELECT Col1, Col2, Col3 FROM StoreList WHERE RetailerId = "yourQueryStringRetailerId"
Note
ReplaceCol1, Col2, Col3
with actual Column Names.
Execute this Query with the help ofADO.NET
objects and pass theQueryString
value correctly to the Query.
这篇关于如何在ASP.Net中创建动态链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!