I have populated a gridview with C#, but the data in the girdview is very close to the cell borders. How can I take away the padding for the cell content with C#?
string query = "SELECT * FROM `fabrica`";
//'bd' and 'ExecuteRead' is my database classe
DataTable table = bd.ExecuteRead(query);
table.Columns["id"].ColumnName = "ID";
table.Columns["nome"].ColumnName = "Nome";
table.Columns["cidade"].ColumnName = "Cidade";
table.Columns["estado"].ColumnName = "Estado";
table.Columns["telefone1"].ColumnName = "Telefone 1";
table.Columns["telefone2"].ColumnName = "Telefone 2";
table.Columns["telefone3"].ColumnName = "Telefone 3";
table.Columns["email1"].ColumnName = "Email 1";
table.Columns["email2"].ColumnName = "Email 2";
table.Columns["email3"].ColumnName = "Email 3";
Tabela.DataSource = table;
Tabela.ControlStyle.Width = 885;
Tabela.DataBind();
You can use CellPadding property.
Tabela.CellPadding = 10;
Reference : http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.cellpadding.aspx
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.