Internet Explorer静态GridView问题

时间:2016-12-07 16:11:37

标签: html css asp.net internet-explorer gridview

我的静态GridView标头有一些非常奇怪的问题。 IE中的线条没有正确排列;他们中的一些人这样做,而其他人则没有。有人可以帮我吗?它在Chrome中完美运行,而不是IE。

铬: Chrome

IE: IE

这是我的相关代码。

    <script type="text/javascript">
                    function MakeStaticHeader(gridId, height, width, headerHeight, isFooter) {
                        var tbl = document.getElementById(gridId);
                        if (tbl) {
                            var DivHR = document.getElementById('DivHeaderRow');
                            var DivMC = document.getElementById('DivMainContent');
                            var DivFR = document.getElementById('DivFooterRow');

                            //*** Set divheaderRow Properties ****
                            DivHR.style.height = headerHeight + 'px';
                            DivHR.style.width = (parseInt(width) - 50) + 'px';
                            DivHR.style.position = 'relative';
                            DivHR.style.top = '0px';
                            DivHR.style.left = (tbl.clientLeft-25) +'px';
                            DivHR.style.zIndex = '10';
                            DivHR.style.verticalAlign = 'top';
                            DivHR.style.alignContent = 'center';

                            //*** Set divMainContent Properties ****
                            DivMC.style.width = width + 'px';
                            DivMC.style.height = height + 'px';
                            DivMC.style.position = 'relative';
                            DivMC.style.top = -headerHeight + 'px';
                            DivMC.style.zIndex = '1';
                            //****Copy Header in divHeaderRow****
                            DivHR.appendChild(tbl.cloneNode(true));
                        }
                    }



                    function OnScrollDiv(Scrollablediv) {
                        document.getElementById('DivHeaderRow').scrollLeft = Scrollablediv.scrollLeft;
                        //if (document.getElementById('DivHeaderRow').scrollLeft >= 300) {
                        //    document.getElementById('DivHeaderRow').scrollLeft = 300;
                        //}
                    }

                </script>

CSS

  html, body {
  margin:0px;
  padding:0px;
  width: 100%;
  box-sizing: border-box;
 }

CSS标题样式

.GVFixedHeader
    {
        font-weight: bold;
        background-color: Green;
        position: relative;
        font-size: 12px;
        text-align: left;
    }

1 个答案:

答案 0 :(得分:0)

它与IE呈现GridView的方式有关。我会自定义更改我在表格的一个单元格上的格式化,但这会弄乱IE并更改默认设置。 Chrome会正确识别我只想添加样式而不是完全更改。

  for (int i = 0; i < e.Row.Cells.Count; i++)
                {
                    if (e.Row.RowType == DataControlRowType.Header)
                    {
                        e.Row.Cells[i].Attributes.Add("style", "white-space: inital;");
                        e.Row.Cells[i].Attributes.Add("style", "text-align: left;");//THIS IS WHAT I ADDED + some altering of the width of the JS
                        if (i == 1)
                        {
                            e.Row.Cells[i].Text = "Make Inactive?";
                        }
                        if (i == 9)
                        {
                            e.Row.Cells[i].Text = "Total Invoice YTD";
                            e.Row.Cells[i].Attributes.Add("style", "white-space: normal;");
                        }
                        if (i == 13)
                        {
                            e.Row.Cells[i].Attributes.Add("style", "white-space: normal;");
                        }
                    }
                    if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Cells[i].Attributes.Add("style", "white-space: nowrap;"); } //ALWAYS makes sure there is no wrapping of text
                }