2016-05-19 60 views
-2

我想在我的GridView中的每一行之間設置線條。我的解決辦法是C#類庫SP:ASP.NET - 在GridView中的每行之間設置線條

這是我的GridView代碼:

SPGridView TableResult = new SPGridView(); 
TableResult.AutoGenerateColumns = false; 
TableResult.Style.Value = " width: 30%; runat:server; text-align: center; background-color:#FAEBD7; margin: 5px 0 10px 0; border: solid 2px #525252; border-collapse:collapse; font-family:Calibri; color: #474747;"; 
TableResult.AllowSorting = true; 
TableResult.Width = 1500; 
TableResult.Font.Size = 15; 
TableResult.CellPadding = 5; 
TableResult.CssClass = "mGrid"; 
TableResult.PagerTemplate = null; 
TableResult.ID = "GridView2"; 
TableResult.GridLines ........................... ? 

更多細節:

DataView mydataview2 = new DataView(table2); 
table2 = mydataview2.ToTable(true, "KmInCity", "KmOutCity", "lKmTotal"); 
TableResult.DataSource = table2; 
TableResult.DataBind(); 
+1

你讀過[這個MSDN(https://msdn.microsoft.com/EN-US/library/c31tzf4s)?只需在SPGridView上快速瀏覽一下,就可以在MSDN上找到該頁面。 – t0mm13b

+0

myGrid.GridLines = GridLines.Horizo​​ntal;與此不工作... – Gohyu

+0

你有一個'System.Web.UI.WebControls'及其相應的DLL的引用? – t0mm13b

回答

0

嘗試下面的代碼

.aspx頁面中

<asp:GridView ID="GridView1" CssClass="grid" GridLines="None" runat="server">  
</asp:GridView> 

風格的GridView

 .grid 
     { 
      width: 855px; 
      background-color: #FFF; 
      border: solid 1px #525252; 
     } 
     .grid td 
     { 
      padding: 2px; 
      border: solid 1px #C1C1C1; 
      color: #333;    
     } 
     .grid th 
     { 
      padding: 3px; 
      color: #FFF; 
      background: #424242 url(grd.png) repeat-x top; 
      border-left: solid 1px #525252;    
     } 

如果您希望通過編程添加它,然後

TableResult.Attributes.Add("class", "grid"); 
TableResult.Attributes.Add("class", "grid td"); 
TableResult.Attributes.Add("class", "grid th"); 
+0

我想這個編程.. – Gohyu

+0

我的解決方案是類庫 – Gohyu

相關問題