0

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?

dda
  • 6,030
  • 2
  • 25
  • 34
Indra
  • 279
  • 2
  • 3
  • 16

3 Answers3

1

Using jQuery:

$("a", $("#<%=Gridview.ClientID%>")).each(function(index){
  $(this).attr("disabled", true);
});
Kapil Khandelwal
  • 15,958
  • 2
  • 45
  • 52
0

You can set columns using index.

if (someCond) 
{ 
  ((BoundField)GridView1.Columns[0]).DataFormatString = "{0:dd-MMM-yyyy}"; 
  ((BoundField)GridView1.Columns[2]).DataFormatString = "{0:f2}"; 
}
Mennan
  • 4,451
  • 13
  • 54
  • 86
0

You Should use Item_Databound event & write code inside it to check for the condition then you can easily disable enable any server side control etc..

Learning
  • 19,469
  • 39
  • 180
  • 373