1

我页面上的 gridview 在每一列中都设置了模板字段,以便我可以输入信息并将其保存到我的数据库中。没有直接与 gridview 关联的数据,只是一次添加多行以保存数据的能力。我用空的文本框显示它,它工作正常,所有它都停止了,现在不会显示了。关于正在发生的事情的任何线索。代码如下...

<asp:GridView ID="gvOLIAdj" runat="server" AutoGenerateColumns="False" CssClass="td8"  CellPadding="4" ForeColor="#333333" PageSize="5" ViewStateMode="Enabled">
  <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    <Columns>
      <asp:TemplateField HeaderText="Approval Date ">
        <EditItemTemplate>
          <asp:Label ID="Label5" runat="server"></asp:Label>              
        </EditItemTemplate>
        <ItemTemplate>
          <asp:TextBox ID="txtAdjAppr" runat="server" CausesValidation="True"></asp:TextBox>
          <asp:MaskedEditExtender ID="txtAdjApprt_MaskedEditExtender" runat="server"   ClearMaskOnLostFocus="False" ClipboardEnabled="False" Mask="99/99/99" TargetControlID="txtAdjAppr" />
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="125px" />
      </asp:TemplateField> 
      <asp:TemplateField HeaderText="Total Amount">
        <EditItemTemplate>
          <asp:Label ID="Label2" runat="server"></asp:Label>                                                                            </EditItemTemplate>
        <ItemTemplate>
          <asp:TextBox ID="txtAdjAmt" runat="server" CausesValidation="True"></asp:TextBox>
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Right" VerticalAlign="Middle" Width="225px" />
      </asp:TemplateField>
      <asp:TemplateField HeaderText="Comments">
        <EditItemTemplate>
          <asp:Label ID="Label3" runat="server"></asp:Label>
        </EditItemTemplate>
        <ItemTemplate>
          <asp:TextBox ID="txtCmmts" runat="server" Width="599" CausesValidation="True"></asp:TextBox>
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />
      </asp:TemplateField>
      <asp:TemplateField>
        <EditItemTemplate>
        <asp:Label ID="Label4" runat="server"></asp:Label>
        </EditItemTemplate>
        <ItemTemplate>
          <asp:Label ID="lblInitials" runat="server"></asp:Label>
        </ItemTemplate>
        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="35px" />
        </asp:TemplateField>
    </Columns>
  <EditRowStyle BackColor="#999999" />
  <FooterStyle BackColor="#003399" Font-Bold="True" ForeColor="White" />
  <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="White" />
  <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
  <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
  <SortedAscendingCellStyle BackColor="#E9E7E2" />
  <SortedAscendingHeaderStyle BackColor="#506C8C" />
  <SortedDescendingCellStyle BackColor="#FFFDF8" />
  <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
4

2 回答 2

1

潜在原因:

  • 您没有设置为编辑模式,gvOLIAdj.EditIndex = 1;
  • CssClass="td8" 设置为 display:none/visibility:hidden
  • gvOLIAdj.Visible=False 正在设置
  • 你升级了你的框架,见下文

GridView 在以前的 .NET 版本中没有设置 EditIndex 属性

于 2012-05-02T12:43:25.930 回答
0

Gridviews must be bound to a datasource of somesort, the view you see in the designer is only an estimation of what the gridview will look like.

于 2012-05-02T12:50:31.967 回答