日期:2014-05-18  浏览次数:20415 次

有关于GridView的小问题、请教各位老师。
我在ASP页面中做了这样的操作详细请看代码相信您会明白我要做的是什么:

  前台代码:

  <table style="text-align: center; width: 100%">
  <tr>
  <td style="width: 100%; height: 64px; text-align: center;">
  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
  DataKeyNames="ID" ForeColor="#333333" GridLines="None" OnRowDeleting="GridView1_RowDeleting"
  OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit"
  Width="100%">
  <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
  <Columns>
  <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" Visible="false" />
  <asp:BoundField DataField="Fill_Time" HeaderText="日期" />
  <asp:BoundField DataField="Goods_Num" HeaderText="配件、设备编号" />
  <asp:BoundField DataField="Goods_Name" HeaderText="品名" />
  <asp:BoundField DataField="Goods_Spce" HeaderText="规格" />
  <asp:BoundField DataField="Goods_Amount" HeaderText="数量" />
  <asp:BoundField DataField="Goods_Money" HeaderText="金额" />
  <asp:BoundField DataField="Storage" HeaderText="使用明细、保管处" />
  <asp:BoundField DataField="Treatment" HeaderText="处置明细" />
  <asp:CommandField HeaderText="选择" ShowSelectButton="True" />
  <asp:CommandField HeaderText="编辑" ShowEditButton="True" />
  <asp:CommandField HeaderText="删除" ShowDeleteButton="True" />
  </Columns>
  <RowStyle ForeColor="#000066" />
  <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
  <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Left" />
  <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
  </asp:GridView>
  <asp:CheckBox ID="CheckBox1" runat="server" Text="经过财务" />
  </td>
  </tr>
  </table>


  后台代码:

  protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
  {
  Database db = new Database();
  string sqlstr = "update Badness_Manage set Fill_Time='"
  + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim() + "',Goods_Num='"
  + ((TextBox)(GridView1.Rows[e