1

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();

1 Answer 1

2

You can use CellPadding property.

Tabela.CellPadding = 10;

Reference : http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.cellpadding.aspx

Sign up to request clarification or add additional context in comments.

3 Comments

Are you using some built-in style for Grid View? or Grid View container override your Grid View style.
If I'm not wrong, that auto format override your CellPadding value.
It's okey, I'm solved with css, because I don't have any other solution

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.