错位列标题

时间:2017-01-05 07:47:07

标签: c# asp.net gridview

我有一个Gridview有3列,其中一个(ObjectiveID)是invisible,使用 CSS

<style type="text/css">
    .hidden {
        display: none;
    }
</style>

但是,当我使用这种风格时,我得到了错位的列标题,如下图所示:

enter image description here

我的Aspx代码:

    <div class="form-group col-md-8">
        <asp:GridView runat="server" ID="grdPlanObjectivesStandardWeights" AutoGenerateColumns="False"
            CssClass="table table-hover table-bordered table-responsive table-striped"
            HeaderStyle-CssClass="tableHeader"
            DataKeyNames="ObjectiveID"
            EmptyDataText="<%$Resources:DCAACommon, NoDataMessage%>"
            EmptyDataRowStyle-CssClass="alert alert-warning"
            EmptyDataRowStyle-HorizontalAlign="Center">
            <Columns>
                <asp:BoundField DataField="ObjectiveID">
                    <ItemStyle CssClass="hidden" />
                </asp:BoundField>
                <asp:BoundField DataField="Name" HeaderText="<%$ Resources:DCAAStrategicManagement, Initiative_ObjectiveName  %>" />
                <asp:TemplateField HeaderText="<%$ Resources:DCAAStrategicManagement, obj_lblStandardWeight  %>" ItemStyle-HorizontalAlign="Center">
                    <ItemTemplate>
                        <asp:TextBox runat="server" ID="txtStandardWeight" onkeypress="return onlyNumbers();" Text='<%# Eval("StandardWeight") %>'></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
            <PagerStyle CssClass="pagination-gridView" />
            <PagerSettings Mode="NumericFirstLast" FirstPageText="First" LastPageText="Last" />
        </asp:GridView>
    </div>

注意:我需要保持 ObjectiveID 不可见,并且我不得对BoundField使用 Visible =“False”

任何帮助都是适用的。

2 个答案:

答案 0 :(得分:1)

我试图只隐藏likesPartial,我所需要的只是隐藏标题。

所以,我改变了这个:

arrayIds[i]

对此:

items

它运作得很好。

答案 1 :(得分:1)

您正在隐藏 ALTER PROCEDURE [dbo].[usp_insert_test2] (@testid int, @age int, @salary decimal, @name varchar(250), @datetime datetime = NULL, @gender bit) AS BEGIN SET NOCOUNT ON; INSERT INTO test2 VALUES (@testid, @age, @salary, @name, ISNULL(@datetime, GETDATE()), @gender) END 项,而不是它的内容。这将导致奇怪的行为。

解决方案是将#include <stdio.h> #include <stdlib.h> struct node //Node { int info; struct node * link; }; //insertion at begin struct node * AddAtBegin(struct node * start, int data) { struct node * p; p = (struct node * ) malloc(sizeof(struct node)); p - > info = data; p - > link = start; start = p; return start; } //insertion at End struct node * AddAtEnd(struct node * start, int data) { struct node * p, * q = start; p = (struct node * ) malloc(sizeof(struct node)); p - > info = data; p - > link = NULL; while (q - > link != NULL) q = q - > link; q - > link = p; return start; } //insertion after any given node struct node * AddAfter(struct node * start, int data, int node) { if (node == ' ') return start; struct node * temp, * p = start; temp = (struct node * ) malloc(sizeof(struct node)); temp - > info = data; while (p != NULL) { if (p - > info == node) { temp - > link = p - > link; p - > link = temp; return start; } p = p - > link; } printf("Not Found Your Node"); return start; } //insertion before any given node struct node * AddBefore(struct node * start, int data, int node) { if (start == NULL) { printf("List is Empty"); return start; } struct node * p, * q = start; p = (struct node * ) malloc(sizeof(struct node)); p - > info = data; if (start - > info == node) { p - > link = start; start = p; return start; } while (q - > link != NULL) { if (q - > link - > info == node) { p - > link = q - > link; q - > link = p; return start; } q = q - > link; } printf("NOT found node"); return start; } // deletion of node int Delete(struct node * start, int data) { struct node * p = start; struct node * temp = NULL; if (start == NULL) { printf("Epty list"); exit(1); } if (p - > info == data) { temp = start; start = p - > link; free(temp); printf("After Deletion of %d == ", data); return 0; } while (p - > link != NULL) { if (p - > link - > info == data) { temp = p - > link; p - > link = temp - > link; free(temp); printf("After Deletion of %d == ", data); return 0; } p = p - > link; } printf("Not Found In The List"); return 0; } //display of all nodes void Display(struct node * start) { struct node * p = start; while (p != NULL) { printf("%d \t", p - > info); p = p - > link; } return; } int main() { struct node * start = NULL; int i; start = AddAtBegin(start, 2); start = AddAtBegin(start, 1); start = AddAtEnd(start, 4); start = AddAtEnd(start, 5); start = AddAfter(start, 6, 5); start = AddAfter(start, 3, 2); start = AddBefore(start, 7, 6); start = AddBefore(start, 79, 1); printf("List is \n"); Display(start); printf("\n"); scanf("%d", & i); Delete(start, i); Display(start); Delete(start, 7); Display(start); Delete(start, 79); Display(start); return 0; } 更改为<td>。你会有更多的控制权。

BoundField