programatically change style (padding) of a column in ASP.NET GridView

泪湿孤枕 提交于 2019-12-22 10:50:36

问题


I need to change padding for one column in ASP.NET GridView, while all other CSS atributes defined in external CSS file should be left untouched. How can I do it?

Thanks in advance!

Update: Below is my code that solved the problem:

protected void gvwMaster_RowDataBound(object sender, GridViewRowEventArgs e)
{
    e.Row.Cells[0].Attributes.Add("style", "padding:0");
}

回答1:


You can tap into RowCommand event, which has e.Row.Cells, which you can change the styles for the cell (should have a styles collection or a CssClass property). I don't think each field (which translates to the column) has a CSS style setting...



来源:https://stackoverflow.com/questions/2342232/programatically-change-style-padding-of-a-column-in-asp-net-gridview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!