asp:HyperLink和存储在数据库中的url不起作用
本文关键字:url 不起作用 数据库 HyperLink 存储 asp | 更新日期: 2023-09-27 18:27:32
I字符串为ExtLinkHPLINK提供extlink列的值,该列是存储在该列中的外部URL。但是,当我把鼠标放在超链接上时,它并没有向我显示有一种方法可以点击它并移动到外部URL,换句话说,超链接不起作用,也不会将我移动到URL。那么我想做什么
<div class="col-lg-12" style="padding-top:48px; padding-bottom:5px;">
<div class="col-lg-12">
For more images and information <asp:HyperLink ID="ExtLinkHPLINK" runat="server" Target="_blank" NavigateUrl='<%# Eval("extlink") %>'>click here</asp:HyperLink>
</div>
</div>
SqlConnection shwadsone = new SqlConnection(cs);
{
shwadsone.Open();
SqlCommand adsdeCM = new SqlCommand();
string adsdetSqlSelect = @"SELECT AD.[AdsID],AD.[UID],AD.[Section],AD.[Category],AD.[Country],AD.[State],AD.[City],AD.[AdsTit] /...,UI.[Logo],UI.[Img],UI.[TeleNum],UI.[Email], FROM [ads] as AD JOIN UserInfo as UI ON AD.[UID] = UI.[UID] where AD.AdsID = @AID ";showernumlbl.Text = adsdetDR["Shower"].ToString();
carmakerlbl.Text = adsdetDR["Maker"].ToString();
Label2.Text = adsdetDR["Garage"].ToString();
CountCurrencLbl.Text = adsdetDR["Currency"].ToString();
ExtLinkHPLINK.NavigateUrl = adsdetDR["extlink"].ToString();/...
设计页面中的代码:
<div class="col-lg-12" style="padding-top:48px; padding-bottom:5px;">
<div class="col-lg-12">
For more images and information
<asp:HyperLink ID="ExtLinkHPLINK" runat="server" Target="_blank">click here</asp:HyperLink>
</div>
</div>
你的代码背后:
string adsdetSqlSelect = @"select AD.[AdsID],
AD.[UID],
AD.[Section],
AD.[Category],
AD.[Country],
AD.[State],
AD.[City],
AD.[AdsTit],
UI.[Logo],
UI.[Img],
UI.[TeleNum],
UI.[Email]
from [ads] as AD
join UserInfo as UI
ON AD.[UID] = UI.[UID]
where AD.AdsID = @AID";
SqlConnection con = new SqlConnection(cs);
SqlCommand adsdeCM = new SqlCommand(adsdetSqlSelect, con);
try{
con.Open();
SqlDataReader sdr = cmd.ExecuteReader();
sdr.Read();
showernumlbl.Text = sdr["Shower"].ToString();
carmakerlbl.Text = sdr["Maker"].ToString();
Label2.Text = sdr["Garage"].ToString();
CountCurrencLbl.Text = sdr["Currency"].ToString();
ExtLinkHPLINK.NavigateUrl = sdr["extlink"].ToString();
}
catch(Exception ex){
//Catch exceptions and work with them
}
finally{
con.Close();
}
我不知道你的表结构,所以我只希望你的表中真的有Shower、Maker和Garage,Currency以及extlink字段,并且这些字段只在一个表中。否则,您必须使用作为指令在查询中重命名它们。希望它能帮助