如何隐藏datagridview的第一列添加仍然获取数据
How to hide first column of datagridview add still get data
我想用 css 隐藏我的 gridview 的第一列,但没有成功。
这里是生成的 html 的一部分。
<table class="mGrid" cellspacing="0" cellpadding="3" rules="all" ridlines="None" border="1" id="PageContent_gvLocation" style="border-collapse:collapse;">
<tbody><tr>
<th scope="col"><a href="javascript:__doPostBack('ctl00$PageContent$gvLocation','Sort$ubicacion_componente_id')">ubicacion id</a></th><th scope="col"><a href="javascript:__doPostBack('ctl00$PageContent$gvLocation','Sort$armario')">Armario</a></th><th scope="col"><a href="javascript:__doPostBack('ctl00$PageContent$gvLocation','Sort$cajon')">Cajon</a></th><th scope="col"> </th>
</tr><tr>
<td>
<span id="PageContent_gvLocation_lblLocationID_0" class="gridTextbox">46</span>
</td><td>
<span id="PageContent_gvLocation_lblCloset_0" class="gridTextbox">testarmariio</span>
</td><td>
<span id="PageContent_gvLocation_lblDrawer_0" class="gridTextbox">testcajon</span>
</td><td>
<input type="image" name="ctl00$PageContent$gvLocation$ctl02$ctl00" title="Edit" src="../Images/edit.png" style="height:20px;width:20px;">
<input type="image" name="ctl00$PageContent$gvLocation$ctl02$ctl01" title="Delete" src="../Images/delete.png" style="height:20px;width:20px;">
</td>
</tr><tr class="alt">
<td>
这是我的 asp.net 代码。
<asp:GridView ID="gvLocation" runat="server" AutoGenerateColumns="false" ShowFooter="true"
ShowHeaderWhenEmpty="true" AllowPaging="True" OnPageIndexChanging="gvLocation_PageIndexChanging"
OnRowEditing="gvLocation_RowEditing" OnRowCancelingEdit="gvLocation_RowCancelingEdit"
AllowSorting="true" onsorting="gvLocation_Sorting" ridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt" CellPadding="3">
<%-- Theme Properties --%>
<Columns>
<asp:TemplateField HeaderText="ubicacion id" SortExpression="ubicacion_componente_id">
<ItemTemplate>
<asp:Label CssClass="gridTextbox" ID="lblLocationID" Text='<%# Eval("ubicacion_componente_id") %>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox CssClass="gridTextbox" ID="txtLocationID" Text='<%# Eval("ubicacion_componente_id") %>' runat="server" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox CssClass="gridTextbox" ID="txtLocationIDFooter" runat="server" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
如何使用 css 隐藏 gridview 的第一列。
如果你想根据你的代码只在CSS中实现,你可以尝试以下
table.mGrid tr td:first-child{
display:none;
}
table.mGrid tr th:first-child{
display:none;
}
寻呼机通常在最后一行可用,您始终可以选择排除 table 的最后一行,使用以下代码:
table.mGrid tr:not(:last-child) td:first-child {
display: none;
}
table.mGrid tr:not(:last-child) th:first-child {
display: none;
}
我想用 css 隐藏我的 gridview 的第一列,但没有成功。
这里是生成的 html 的一部分。
<table class="mGrid" cellspacing="0" cellpadding="3" rules="all" ridlines="None" border="1" id="PageContent_gvLocation" style="border-collapse:collapse;">
<tbody><tr>
<th scope="col"><a href="javascript:__doPostBack('ctl00$PageContent$gvLocation','Sort$ubicacion_componente_id')">ubicacion id</a></th><th scope="col"><a href="javascript:__doPostBack('ctl00$PageContent$gvLocation','Sort$armario')">Armario</a></th><th scope="col"><a href="javascript:__doPostBack('ctl00$PageContent$gvLocation','Sort$cajon')">Cajon</a></th><th scope="col"> </th>
</tr><tr>
<td>
<span id="PageContent_gvLocation_lblLocationID_0" class="gridTextbox">46</span>
</td><td>
<span id="PageContent_gvLocation_lblCloset_0" class="gridTextbox">testarmariio</span>
</td><td>
<span id="PageContent_gvLocation_lblDrawer_0" class="gridTextbox">testcajon</span>
</td><td>
<input type="image" name="ctl00$PageContent$gvLocation$ctl02$ctl00" title="Edit" src="../Images/edit.png" style="height:20px;width:20px;">
<input type="image" name="ctl00$PageContent$gvLocation$ctl02$ctl01" title="Delete" src="../Images/delete.png" style="height:20px;width:20px;">
</td>
</tr><tr class="alt">
<td>
这是我的 asp.net 代码。
<asp:GridView ID="gvLocation" runat="server" AutoGenerateColumns="false" ShowFooter="true"
ShowHeaderWhenEmpty="true" AllowPaging="True" OnPageIndexChanging="gvLocation_PageIndexChanging"
OnRowEditing="gvLocation_RowEditing" OnRowCancelingEdit="gvLocation_RowCancelingEdit"
AllowSorting="true" onsorting="gvLocation_Sorting" ridLines="None" CssClass="mGrid" PagerStyle-CssClass="pgr" AlternatingRowStyle-CssClass="alt" CellPadding="3">
<%-- Theme Properties --%>
<Columns>
<asp:TemplateField HeaderText="ubicacion id" SortExpression="ubicacion_componente_id">
<ItemTemplate>
<asp:Label CssClass="gridTextbox" ID="lblLocationID" Text='<%# Eval("ubicacion_componente_id") %>' runat="server" />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox CssClass="gridTextbox" ID="txtLocationID" Text='<%# Eval("ubicacion_componente_id") %>' runat="server" />
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox CssClass="gridTextbox" ID="txtLocationIDFooter" runat="server" />
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
如何使用 css 隐藏 gridview 的第一列。
如果你想根据你的代码只在CSS中实现,你可以尝试以下
table.mGrid tr td:first-child{
display:none;
}
table.mGrid tr th:first-child{
display:none;
}
寻呼机通常在最后一行可用,您始终可以选择排除 table 的最后一行,使用以下代码:
table.mGrid tr:not(:last-child) td:first-child {
display: none;
}
table.mGrid tr:not(:last-child) th:first-child {
display: none;
}