Frage

I've written a server control that extends the standard .net Gridview control.

However, by default the standard gridview control adds a border="0" attribute to the html markup that it produces, and I want to prevent this attribute from being rendered by my server control.

I could probably use ScriptManager to add a bit of Javascript that removes the attribute once the page that the control sits on has loaded, but that seems a bit clunky and I was hoping that somebody could tell me how to do it cleanly by, for example, adding this.Attributes.Remove("border"); to the PreRender event of the control or something similar (which didn't work by the way, or I wouldn't have to ask the question)

War es hilfreich?

Lösung

I am using a devexpress gridview so it might be a bit different, but I noticed the same thing happening, and I added

grid.Attributes["border"] = "";

to the page load event, and the border no longer rendered in html. A bit of a hack but it worked for me.

Andere Tipps

All you need to do is set Gridlines to "None"

refer: GridLines property of the GridView.

<asp:GridView GridLines="None" />

Ofcourse, if you want more control over the rendering, control adapters are what you are looking for.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top