在网格上显示网格线

时间:2010-03-10 20:06:19

标签: c# asp.net visual-studio telerik radgrid

我正在使用Rad Grids,我使用内置皮肤进行外观。但是,我想为我的网格添加网格线。 Gridlines =“Both”似乎不起作用。

 <telerik:RadGrid ID="RadGridProviders" Width="100%" GridLines="Both" AllowPaging="true" Skin="WebBlue" runat="server"  DataSourceID="SDSProvider" AutoGenerateColumns="false">
                    <MasterTableView DataSourceID="SDSProvider" PageSize="7" CellPadding="0" GridLines="Both" CellSpacing="0" DataKeyNames="ID,Entry_Loc" AllowMultiColumnSorting="True" AutoGenerateColumns="false"  >
                     <PagerStyle Mode="NextPrevNumericAndAdvanced"/>
                     <Columns>
                        <telerik:GridBoundColumn HeaderText="Organization Name" HeaderStyle-HorizontalAlign="Center" DataField="OrgName" SortExpression="OrgName">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Provider Type" HeaderStyle-HorizontalAlign="Center" DataField="TypeofProvider" SortExpression="TypeofProvider">
                        </telerik:GridBoundColumn>
                         <telerik:GridBoundColumn HeaderText="Contact Name" HeaderStyle-HorizontalAlign="Center" DataField="Contact" SortExpression="Contact">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Address" HeaderStyle-HorizontalAlign="Center" DataField="Address" SortExpression="Address">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Contact Number" HeaderStyle-HorizontalAlign="Center" DataField="Phone" SortExpression="Phone">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn HeaderText="Creator Location" Visible="false" HeaderStyle-HorizontalAlign="Center" DataField="Entry_Loc" SortExpression="Entry_Loc">
                        </telerik:GridBoundColumn>
                        <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" HeaderText="Delete Provider" HeaderStyle-HorizontalAlign="Center" 
                            ConfirmText="Are You Sure You Want to Delete this Provider?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete Provider Confirmation"
                            UniqueName="DeleteProv">
                        </telerik:GridButtonColumn> 
                     </Columns>
                    </MasterTableView>
                    </telerik:RadGrid>

我刚尝试添加自定义CSS

.mytable tr td
    {
                border: solid 1px #000000;
    }

我在masterr表中设置了项目样式的css类,我将它设置在主表和网格本身上。没用。

2 个答案:

答案 0 :(得分:2)

您的皮肤可能不支持网格线。您可以尝试使用其他皮肤来检查或使用firebug。如果皮肤不支持网格线,则需要使用自定义css / skin手动添加它们。

以下是RadGrid css类的说明: http://www.telerik.com/help/aspnet-ajax/grdcreatingnewskins.html

您可以尝试自定义现有皮肤或使用以下内容:

.RadGrid_WebBlue .rgRow td
{
    border: solid 1px #000000;
}

答案 1 :(得分:0)

protected void Page_Load(object sender, EventArgs e)
{
    this.GridView1.Attributes.Add("bordercolor", "c3cecc");
}

“使用GridView,声明性bordercolor属性添加内联样式声明,该声明仅适用于表本身,而不适用于单个单元格。

以编程方式添加bordercolor属性不使用内联样式,而是使用HTML bordercolor属性,这些属性适用于表中的所有边框。“

这是Lee Dumond在我关于这个主题的博客文章中发表的评论:

http://codersbarn.com/post/2009/05/31/Set-Color-of-GridLines-in-Gridview.aspx