没有网址时更改超链接颜色 [英] Change Hyperlink Colour when their's no url
问题描述
美好的一天
我已经在ASP.Net应用程序中创建了一个数据列表.我将所有来自SQL的数据绑定到一个数据表中,并在数据列表中显示该数据.我正在将certian数据显示到数据列表中的超链接.
我想更改数据列表中的证书超链接颜色.我遇到的问题是,当我更改超链接的颜色时,所有超链接的颜色都会改变.
我想知道如果超链接没有"url"时如何更改数据列表中特定超链接的颜色?
谢谢.
Good day
I have created a datalist in an ASP.Net application. I am binding all the data from SQL into a datatable and display the data in the datalist. I am displaying certian data to Hyperlinks inside the datalist.
I want to change certian Hyperlinks colours in the Datalist. My problem that I have is when I change the colour of the Hyperlink all the colours of the Hyperlinks change.
I want to know how can I change the colour of a specefic Hyperlink inside the datalist if the Hyperlink has no "url"?
Thanks.
推荐答案
绑定数据列表后,只需调用下面的给定函数即可.
Hi,
After binding your datalist just you need to call the given function below.
private void fnChangeLinkStyle(){
foreach (DataListItem dli in DataList1.Items)
{
if (dli.ItemType == ListItemType.Item || dli.ItemType == ListItemType.AlternatingItem)
{
HyperLink btn = dli.FindControl("HyperLink1") as HyperLink;
if(btn.NavigateUrl=""){
//Change the hyperlink style here.
}
}
}
}
祝一切顺利.
--Amit
All the best.
--Amit
这篇关于没有网址时更改超链接颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!