I want to remove a clickable link from asp:Gridview column when some condition is true.
I tried this:
Gridview.attributes["disabled"] = "disabled";
But the hyperlink is still clickable. I don't want clickable hyperlinks when the grid is disabled. How can I do it in C#.net?
Using jQuery:
$("a", $("#<%=Gridview.ClientID%>")).each(function(index){
$(this).attr("disabled", true);
});
You can set columns using index.
if (someCond)
{
((BoundField)GridView1.Columns[0]).DataFormatString = "{0:dd-MMM-yyyy}";
((BoundField)GridView1.Columns[2]).DataFormatString = "{0:f2}";
}
您应该使用Item_Databound
事件并在其中写入代码来检查条件,然后您可以轻松地禁用启用任何服务器端控件等。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.