Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 设置gridview的标题和单元格的宽度_Asp.net_Css_Gridview - Fatal编程技术网

Asp.net 设置gridview的标题和单元格的宽度

Asp.net 设置gridview的标题和单元格的宽度,asp.net,css,gridview,Asp.net,Css,Gridview,我有一个显示16列gridview的页面。此gridview可水平滚动,并使用CSS设计。我的问题是,每当我尝试设置宽度时,无论是ItemStyle宽度还是HeaderStyle宽度,都不会影响宽度 这是我的CSS: .mGrid { background-color: #fff; margin: 5px 0 10px 0; border: solid 1px #525252; border-collapse:collapse; font-fami

我有一个显示16列gridview的页面。此gridview可水平滚动,并使用CSS设计。我的问题是,每当我尝试设置宽度时,无论是ItemStyle宽度还是HeaderStyle宽度,都不会影响宽度

这是我的CSS:

.mGrid { 
    background-color: #fff; 
    margin: 5px 0 10px 0; 
    border: solid 1px #525252; 
    border-collapse:collapse;
    font-family: Calibri;
    font-size: 12px; 
    white-space:nowrap;
    table-layout:auto;
}

.hideGridColumn
{
    display:none;
}

.mGrid td { 
    padding: 2px; 
    border: solid 1px #c1c1c1; 
    color: #717171;    
    white-space:nowrap;
    table-layout:auto;
    font-family: Microsoft Sans Serif;
    font-size: 0.9em;
}
.mGrid th { 
    padding: 4px 2px; 
    color: #fff; 
    background: #424242 url(grd_head.png) repeat-x top; 
    border-left: solid 1px #525252; 
    font-size: 0.9em;
    font-family: Microsoft Sans Serif;
    text-align: center;
}
.mGrid .alt { background: #fcfcfc url(grd_alt.png) repeat-x top; }
.mGrid .pgr { background: #424242 url(grd_pgr.png) repeat-x top; }
.mGrid .pgr table { margin: 5px 0; }
.mGrid .pgr td { 
    border-width: 0; 
    padding: 0 6px; 
    border-left: solid 1px #666; 
    font-weight: bold; 
    color: #fff; 
    line-height: 12px; 
 }   
.mGrid .pgr a { color: #666; text-decoration: none; }
.mGrid .pgr a:hover { color: #000; text-decoration: none; }
.GridDock
{
    overflow-x: auto;
    overflow-y: hidden;
    width: 200px;
    padding: 0 0 17px 0;
}
以及ASP.net代码的摘录:

<div id="dvScreenWidth" visible="false">
        <div class="GridDock" id="dvGridWidth">
             <asp:GridView ID="gvResults" runat="server" 
                      GridLines="None"
                      CssClass="mGrid" AutoGenerateColumns="false"
                      AllowPaging="true" PagerStyle-CssClass="pgr"
                      PageSize="30">
                <PagerSettings Position="Top" />
                <PagerStyle CssClass="pgr" />
                <Columns>
                     <asp:BoundField DataField="DateAndTimeInspected" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="INSPECTION TIMESTAMP" SortExpression="DateAndTimeInspected" />
                     <asp:BoundField DataField="QA Inspector" ItemStyle-Height="35" HeaderStyle-Height="35"  HeaderText="QA INSPECTOR" SortExpression="QA Inspector" />
                     <asp:BoundField DataField="FT_TESTED/UNTESTED" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="TESTED / UNTESTED" SortExpression="FT_TESTED/UNTESTED" />
                     <asp:BoundField DataField="productname" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="DEVICE" SortExpression="productname" />
                     <asp:BoundField DataField="containername" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="LOT NUMBER" SortExpression="containername" />
                     <asp:BoundField DataField="packagetype" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="PACKAGE TYPE" SortExpression="packagetype" />
                     <asp:BoundField DataField="datecode" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="DATE CODE" SortExpression="datecode" />
                     <asp:BoundField DataField="assysite" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="ASSEMBLY SITE" SortExpression="assysite" />
                     <asp:BoundField DataField="FT_SUBCON_TEST" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="FINAL TEST SITE" SortExpression="FT_SUBCON_TEST" />
                     <asp:BoundField DataField="moveoutqty" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="LOT QUANTITY" SortExpression="moveoutqty" />
                     <asp:BoundField DataField="FT_IQA_SAMPLE_SIZE" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="SAMPLE SIZE" SortExpression="FT_IQA_SAMPLE_SIZE" />
                     <asp:BoundField DataField="FT_IQA_SAMPLE_REJECT" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="SAMPLE REJECT" SortExpression="FT_IQA_SAMPLE_REJECT" />
                     <asp:BoundField DataField="FT_REJECT CATEGORY" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="REJECT CATEGORY" SortExpression="FT_REJECT CATEGORY" />
                     <asp:BoundField DataField="FT_IQA_DISPOSITION" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="IQA DISPOSITION" SortExpression="FT_IQA_DISPOSITION" />
                     <asp:BoundField DataField="FT_DMR#" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="DMR NUMBER" SortExpression="FT_DMR#" />
                     <asp:BoundField DataField="Remarks" ItemStyle-Height="35" HeaderStyle-Height="35" HeaderText="REMARKS" SortExpression="Remarks" />
                </Columns>
             </asp:GridView>
        </div>
    </div> 

    <script type="text/javascript">
        function thirty_pc() {
            var height = $(window).height();
            var thirtypc = (100 * (height - 167)) / 100;
            thirtypc = parseInt(thirtypc) + 'px';
            $("#divContent").css('height', thirtypc);

        }

        $(document).ready(function() {
            thirty_pc();
            $(window).bind('resize', thirty_pc);


        });
        $(document).keypress(function(event) {
            if (event.which == 13) {
                $("#ctl00_cphContent_searchFilter_btnSearch").focus();
                $("#ctl00_cphContent_searchFilter_btnSearch").click();
            }
        });


        $(document).ready(function() {
           $('#dvGridWidth').width($('#dvScreenWidth').width());            
        });

    </script>

函数三十(pc){
var height=$(window.height();
变量thirtypc=(100*(高度-167))/100;
thirtypc=parseInt(thirtypc)+‘px’;
$(“#divContent”).css('height',thirtypc);
}
$(文档).ready(函数(){
三十个人;
$(窗口).bind('resize',三十个pc);
});
$(文档).按键(功能(事件){
if(event.which==13){
$(“#ctl00_cphContent_searchFilter_btnSearch”).focus();
$(“#ctl00_cphContent_searchFilter_btnSearch”)。单击();
}
});
$(文档).ready(函数(){
$('dvGridWidth').width($('dvScreenWidth').width());
});

我真的很感激你能给我的任何帮助。非常感谢。

表格中每个单元格的宽度都会根据表格的宽度自动调整。试着在你的桌子上设置一个固定的宽度

<asp:GridView Width="2000px"

我在边界字段中没有看到任何ItemStyle宽度,只有高度。还是你想改为在css上设置宽度?我的错。但即使我尝试设置itemstyle宽度,也会显示相同的单元格宽度。嗨,这确实适用于我找到的另一个解决方案。但我想我会用这个。
.mGrid { 
    width: 2000px;
}

.mGrid td { 
    width: 6.25%; /* 100% / 16 = 6.25 */
}