日期:2014-05-17  浏览次数:20416 次

为什么无法获取gridview编辑状态下的新值
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
  {
  this.GridView1.EditIndex = -1;
  this.bintNews();
   
  string newID = ((TextBox)this.GridView1.Rows[e.RowIndex].FindControl("t1")).Text.Trim();
   
  //string title = ((TextBox)this.GridView1.Rows[e.RowIndex].Cells[1].FindControl("textbox")).Text;
 
  //Response.Write(title);
  Response.Write(newID);
   
  }

前台

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
  ForeColor="#333333" GridLines="None" Height="148px" Width="584px" OnRowDataBound="GridView1_RowDataBound" OnRowDeleting="GridView1_RowDeleting" OnRowEditing="GridView1_RowEditing" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowUpdating="GridView1_RowUpdating" AllowPaging="True" OnPageIndexChanging="GridView1_PageIndexChanging" PageSize="5">
   
  <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
  <RowStyle BackColor="#EFF3FB" />
  <Columns>
  <asp:BoundField DataField="ID" HeaderText="新闻编号" />
  <asp:BoundField DataField="Title" HeaderText="标题" />
  <asp:BoundField DataField="Content" HeaderText="内容" />
  <asp:BoundField DataField="pubTime" HeaderText="发表时间" />
  <asp:BoundField DataField="remark" HeaderText="备注" />
  <asp:BoundField DataField="Hits" HeaderText="点击数" />
  <asp:CommandField HeaderText="删除" ShowDeleteButton="True" />
  <asp:CommandField HeaderText="编辑" ShowEditButton="True" />
  <asp:TemplateField>
  <ItemTemplate>
  &nbsp;
  </ItemTemplate>
  <EditItemTemplate>
  <asp:TextBox ID="t1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem,"Title") %>'></asp:TextBox>
   
  </EditItemTemplate>
  </asp:TemplateField>
  </Columns>
   
  <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
  <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
  <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
  <EditRowStyle BackColor="#2461BF" />
  <AlternatingRowStyle BackColor="White&qu