GridView主键是哪个啊?

<asp:GridView ID="PageGrid" runat="server" AutoGenerateColumns="False" CssClass="dgv"Width="100%" DataKeyNames="Id" OnRowDataBound="PageGrid_RowDataBound">
  <Columns>
    <asp:TemplateField>
      <ItemTemplate>
        <asp:CheckBox ID="chkitem" runat="server" />
      </ItemTemplate>
      <HeaderStyle Width="30px" />     </asp:TemplateField>       <asp:TemplateField>         <ItemTemplate>           <asp:Label ID="lblRowNumber" runat="server" Text='<%# Container.DataItemIndex + 1 %>'></asp:Label>           <asp:HiddenField ID="hfReimId" runat="server"></asp:HiddenField>         </ItemTemplate>           <HeaderStyle Width="30px" />        </asp:TemplateField>        <asp:TemplateField HeaderText="填写时间">
        <ItemTemplate>           <asp:TextBox ID="txtFillDate" CssClass="easyui-datebox" runat="server" Width="120px" Text='<%# Eval("FillDate") %>'></asp:TextBox>   </ItemTemplate>
          <HeaderStyle Width="80px" />
        </asp:TemplateField>   </Columns> </asp:GridView>
红糖糍粑
浏览 519回答 2
2回答

呼如林

DataKeyNames表示主键的列名,可以通过GridViewEntity.DataKeys[RowIndex]["ColumsName"]来获取它的值
打开App,查看更多内容
随时随地看视频慕课网APP