This is a migrated thread and some comments may be shown as answers.

Unable to suppress GridLines

3 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 01 Feb 2011, 06:11 PM
Hello,

I have a scenario where I am using a RadGrid to display Terms and Conditions to the user.  I have turned off headers and attempted to turn off all grid lines.  I am having an issue where there are faint lines appearing and I have not been able to turn them off.  The code is included.  I believe that with this code, someone should be able to replicate the issue (seems like there is a faint line under every second row).  Help would greatly be appreciated.

Designer Code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HideGridLines.aspx.cs"
    Inherits="Test.HideGridLines" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="ScriptManager" runat="server" />
    <table width="763" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td valign="top">
                <asp:UpdatePanel ID="UpdatePanelOptIn" runat="server">
                    <ContentTemplate>
                        <telerik:RadGrid ID="RadGridOptIn" runat="server" AutoGenerateColumns="false" ShowHeader="false"
                            ItemStyle-BackColor="Transparent" AlternatingItemStyle-BackColor="Transparent"
                            BorderColor="Transparent" OnItemDataBound="RadGridOptIn_ItemDataBound">
                            <MasterTableView DataKeyNames="OptInTypeId" BackColor="Transparent" BorderColor="Transparent"
                                GridLines="None">
                                <Columns>
                                    <telerik:GridTemplateColumn DataField="IsRequired" ItemStyle-HorizontalAlign="Right"
                                        ItemStyle-VerticalAlign="Top">
                                        <ItemTemplate>
                                            <asp:PlaceHolder ID="plhOptInRequired" runat="server" />
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn UniqueName="IsSelected" ItemStyle-HorizontalAlign="Left"
                                        ItemStyle-VerticalAlign="Top">
                                        <ItemTemplate>
                                            <asp:CheckBox ID="cboIsSelected" runat="server" AutoPostBack="true" OnCheckedChanged="cboIsSelected_CheckedChanged"
                                                TabIndex="30" />
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridBoundColumn DataField="OptInHtml" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="Top" />
                                </Columns>
                            </MasterTableView>
                        </telerik:RadGrid>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>

Code Behind Page
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
  
using Telerik.Web.UI;
  
namespace Test
{
    public partial class HideGridLines : System.Web.UI.Page
    {
        #region Properties
  
        #region HcpOptIns
        private UserProfileOptInList HcpOptIns
        {
            get
            {
                if (ViewState["HcpOptIns"] == null)
                {
                    ViewState["HcpOptIns"] = UserProfileOptInList.GetUserProfileOptInList();
                }
                return (UserProfileOptInList)ViewState["HcpOptIns"];
            }
            set
            {
                ViewState["HcpOptIns"] = value;
            }
        }
        #endregion
  
        #endregion
  
        #region Events
  
        #region cboIsSelected_CheckedChanged
        protected void cboIsSelected_CheckedChanged(object sender, EventArgs e)
        {
            try
            {
                CheckBox optIn = (CheckBox)sender;
                bool isSelected = optIn.Checked;
  
                GridDataItem item = (GridDataItem)optIn.NamingContainer;
  
                // get UserProfileOptInCollection record by datakey from the grid
                long optInTypeID = Convert.ToInt64(item.GetDataKeyValue("OptInTypeId"));
  
                UserProfileOptIn regOptIn = HcpOptIns.ItemByOptInTypeId(optInTypeID);
                regOptIn.IsSelected = isSelected;
  
                BindOptIns();
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }
        #endregion
  
        #region Page_Load
        protected void Page_Load(object sender, EventArgs e)
        {
            BindOptIns();
        }
        #endregion
  
        #region RadGridOptIn_ItemDataBound
        protected void RadGridOptIn_ItemDataBound(object sender, GridItemEventArgs e)
        {
            try
            {
                if (e.Item is GridDataItem)
                {
                    if (e.Item.DataItem is UserProfileOptIn)
                    {
                        PlaceHolder plhOptInRequired = (PlaceHolder)e.Item.FindControl("plhOptInRequired");
                        CheckBox chkOptIn = (CheckBox)e.Item.FindControl("cboIsSelected");
                        UserProfileOptIn optIn = (UserProfileOptIn)e.Item.DataItem;
                        System.Web.UI.WebControls.Image imgESignature = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgESignature");
  
                        if (optIn.IsRequired)
                        {
                            AddContentToPlaceHolderControl(@"<span class=""RequiredFieldAsterik"">  * </span>", ref plhOptInRequired);
                        }
                        else
                        {
                            AddContentToPlaceHolderControl(" ", ref plhOptInRequired);
                        }
  
                        if (optIn.IsSelected)
                        {
                            chkOptIn.Checked = true;
                        }
                        else
                        {
                            chkOptIn.Checked = false;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }
        #endregion
  
        #endregion
  
        #region Methods
  
        #region AddContentToPlaceHolderControl
        /// <summary>
        /// Method to indicate required fields
        /// </summary>
        /// <param name="controlHTML">HTML Literal Control to be added to the PlaceHolder Control.</param>
        /// <param name="inputPlaceHolderControl">PlaceHolder Control that will have literal control added to it.</param>
        public static void AddContentToPlaceHolderControl(string controlHTML, ref PlaceHolder inputPlaceHolderControl)
        {
            Literal htmlForPlaceHolder = new Literal();
            htmlForPlaceHolder.Text = controlHTML;
  
            inputPlaceHolderControl.Controls.Add(htmlForPlaceHolder);
        }
        #endregion
  
        #region BindOptIns
        private void BindOptIns()
        {
            RadGridOptIn.DataSource = HcpOptIns;
            RadGridOptIn.DataBind();
        }
        #endregion
  
        #endregion
    }
}

UserProfileOptIn Class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
  
namespace Test
{
    [Serializable]
    public class UserProfileOptIn
    {
        #region Instance Variables
        private long _userProfileOptInTypeId;
        private long _optInTypeId;
        private bool _isRequired;
        private bool _isDisplayed;
        private bool _isSelected;
        private string _optInHtml = string.Empty;
        #endregion
  
        #region Properties
        public long UserProfileOptInTypeId
        {
            get { return this._userProfileOptInTypeId; }
            set { this._userProfileOptInTypeId = value; }
        }
  
        public long OptInTypeId
        {
            get { return this._optInTypeId; }
            set { this._optInTypeId = value; }
        }
  
        public bool IsRequired
        {
            get { return this._isRequired; }
        }
  
        public bool IsDisplayed
        {
            get { return this._isDisplayed; }
            set { this._isDisplayed = value; }
        }
  
        public bool IsSelected
        {
            get { return this._isSelected; }
            set { this._isSelected = value; }
        }
          
        public string OptInHtml
        {
            get { return this._optInHtml; }
            set { this._optInHtml = value; }
        }
        #endregion
  
        #region Constructor
        private UserProfileOptIn(long userProfileOptInTypeId, long optInTypeId, bool isRequired, bool isDisplayed, bool isSelected, string optInHtml)
        {
            this._userProfileOptInTypeId = userProfileOptInTypeId;
            this._optInTypeId = optInTypeId;
            this._isRequired = isRequired;
            this._isDisplayed = isDisplayed;
            this._isSelected = isSelected;
            this._optInHtml = optInHtml;
        }
        #endregion
  
        #region Factory Methods
        public static UserProfileOptIn NewUserProfileOptInt(long userProfileOptInTypeId, long optInTypeId, bool isRequired, bool isDisplayed, bool isSelected, string optInHtml)
        {
            return new UserProfileOptIn(userProfileOptInTypeId, optInTypeId, isRequired, isDisplayed, isSelected, optInHtml);
        }
        #endregion
    }
  
    [Serializable()]
    public class UserProfileOptInList : List<UserProfileOptIn>
    {
        #region Constructor
        private UserProfileOptInList(bool getList)
        {
            if (getList)
            {
                this.Add(UserProfileOptIn.NewUserProfileOptInt(1, 1, true, true, false, "This is the first condition."));
                this.Add(UserProfileOptIn.NewUserProfileOptInt(2, 3, true, true, false, "This is the second condition."));
                this.Add(UserProfileOptIn.NewUserProfileOptInt(3, 1, true, true, false, "This is the third condition."));
                this.Add(UserProfileOptIn.NewUserProfileOptInt(4, 4, true, true, false, "This is the fourth condition."));
                this.Add(UserProfileOptIn.NewUserProfileOptInt(5, 5, true, true, false, "This is the fifth condition."));
                this.Add(UserProfileOptIn.NewUserProfileOptInt(6, 6, true, true, false, "This is the sixth condition."));
            }
        }
        #endregion
  
        #region Factory Methods
        public static UserProfileOptInList NewUserProfileOptInList()
        {
            return new UserProfileOptInList(false);
        }
  
        public static UserProfileOptInList GetUserProfileOptInList()
        {
            return new UserProfileOptInList(true);
        }
        #endregion
  
        #region Methods
        public UserProfileOptIn ItemByOptInTypeId(long optInTypeId)
        {
            foreach (UserProfileOptIn userProfileOptInItem in this)
            {
                if (userProfileOptInItem.OptInTypeId == optInTypeId)
                {
                    return userProfileOptInItem;
                }
            }
            return null;
        }
        #endregion
    }
}



Thanks,

3 Answers, 1 is accepted

Sort by
0
Tom
Top achievements
Rank 1
answered on 03 Feb 2011, 12:44 AM
Does anyone know how to fix this problem (I need to release the software soon).  The faint blue lines occur after every 2nd row in the grid.  Is there a setting that will prevent this?

Thanks,
0
Pavlina
Telerik team
answered on 03 Feb 2011, 01:01 PM
Hi Tom,

Go through the code library below:
http://www.telerik.com/community/code-library/aspnet-ajax/grid/how-to-add-or-remove-radgrid-borders.aspx

All the best,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Tom
Top achievements
Rank 1
answered on 03 Feb 2011, 08:48 PM
Pavlina,

Thank you for the reply.  The style worked perfectly.  I think the problem had to do with alternating colors and that is why there was a faint underline after every 2 rows.

Thanks,
Tags
Grid
Asked by
Tom
Top achievements
Rank 1
Answers by
Tom
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or