C# 关于ASP网格视图的一些非常奇怪的事情

C# 关于ASP网格视图的一些非常奇怪的事情,c#,asp.net,gridview,C#,Asp.net,Gridview,我在Asp中创建了一个GridView,其中有1个BoundField、1个Button Field、1个command Field、1个template Field和按钮,下面是代码 <asp:GridView runat="server" ID="rdGrid" ForeColor="#333333" BorderWidth="1px"> <Columns> <asp:BoundField HeaderText="Description"

我在Asp中创建了一个GridView,其中有1个BoundField、1个Button Field、1个command Field、1个template Field和按钮,下面是代码

<asp:GridView runat="server" ID="rdGrid" ForeColor="#333333" BorderWidth="1px">
    <Columns>
        <asp:BoundField HeaderText="Description" DataField="Description" />
        <asp:ButtonField Text="View Summary" CommandName="Summary" ControlStyle-CssClass="btn btn-primary btn-small" ControlStyle-ForeColor="White" />
        <asp:CommandField EditText="Edit" ShowEditButton="true" ControlStyle-CssClass="btn btn-primary btn-small" ControlStyle-ForeColor="White"></asp:CommandField>
        <asp:TemplateField HeaderText="Delete">
             <ItemTemplate>
                 <asp:Button ID="deleteButton" CssClass="btn btn-danger btn-small" runat="server" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure you want to delete this Player?');" />
                  <%--<asp:HiddenField id="rdId" Value='<%# Eval("roundId") %>' runat="server" />--%>
             </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

根据您在网格视图中的图像,您有两列作为说明,似乎您必须
AutoGenerateColumns
在网格视图中为false,如下所示

<asp:GridView runat="server"  AutoGenerateColumns="false" ID="rdGrid" ForeColor="#333333" BorderWidth="1px">

对于round ID,我认为您使用gridview的DataKeyNames属性


:它起作用了。。对Hiddenfield Eval有什么帮助吗??它说它在当前环境中不存在。。给予exception@SiddharthKoya你能用你如何将数据绑定到网格的代码更新这个问题吗。。对不起,耽搁了。。我用代码更新了问题以绑定网格
<asp:GridView runat="server"  AutoGenerateColumns="false" ID="rdGrid" ForeColor="#333333" BorderWidth="1px">
select roundId, Description, ....  from YourTable