Gridview生成选择具有AutoGenerateSelectButton =“false”的列

时间:2013-03-27 23:01:22

标签: asp.net gridview

我有一个ASP:Gridview,即使AutoGenerateSelectButton =“false”也会生成一个选择列。这是宣言:

    <asp:GridView ID="grdAssessments" runat="server" 
    AutoGenerateColumns="False"
    CssClass="gridview" 
    AlternatingRowStyle-CssClass="even" 
    AutoGenerateSelectButton="false"
    DataKeyNames="ReportId" 
    AllowSorting="True" Width="1000px"
    OnSelectedIndexChanging="grdAssessments_SelectedIndexChanging"
    OnSorting="grdAssessments_Sorting"
    OnRowCommand="grdAssessments_RowCommand"
    OnRowDataBound="grdAssessments_RowDataBound">
    <AlternatingRowStyle CssClass="even" />
    <Columns>
         <asp:TemplateField HeaderText="Edit">
             <ItemTemplate>
                  <a href="javascript:void(0);" 
onclick="showEmployeeEdit('<%# Eval("EmployeeNumber") %>')" title="Edit">Edit</a>
             </ItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderText="DateCreated" SortExpression="DateCreated">
               <ItemTemplate>
                    <asp:Label ID="lblDateCreated" runat="server" />
               </ItemTemplate>
         </asp:TemplateField>
...
   </Columns>
</asp:GridView>

这是结果gridview ...我想要删除的Select列。

enter image description here

2 个答案:

答案 0 :(得分:0)

在黑暗中拍摄:不要连接OnSelectedIndexChanging事件。如果没有某种类型的Select Button,你为什么要这样呢?

答案 1 :(得分:0)

解决方案是:grdAssessments.AutoGenerateSelectButton = false;

我不知道为什么这会解决问题,但确实如此。