如何使用C#为gridview数据设置填充?

时间:2013-05-04 02:21:44

标签: c# asp.net gridview padding

我用C#填充了gridview,但gridview中的数据非常接近单元格边框。如何用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 个答案:

答案 0 :(得分:2)

您可以使用CellPadding属性。

Tabela.CellPadding = 10;

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