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="re" HeaderText="备注" />
<asp:BoundField DataField="Hits" HeaderText="点击数" />
<asp:CommandField HeaderText="删除" ShowDeleteButton="True" />
<asp:CommandField HeaderText="编辑" ShowEditButton="True" />
<asp:TemplateField>
<ItemTemplate>
</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" />
</asp:GridView>
问题:各位高手,怎么就是获取不到要编辑列的值啊。
{
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="re" HeaderText="备注" />
<asp:BoundField DataField="Hits" HeaderText="点击数" />
<asp:CommandField HeaderText="删除" ShowDeleteButton="True" />
<asp:CommandField HeaderText="编辑" ShowEditButton="True" />
<asp:TemplateField>
<ItemTemplate>
</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" />
</asp:GridView>
问题:各位高手,怎么就是获取不到要编辑列的值啊。
解决方案 »
- 庖丁解牛 第二问 [DefaultProperty("TextBoxValue")] 什么作用?DefaultProperty("TextBoxValue"
- TextBox左键定位不到了
- sql proc 寻找高效方法
- ASP.Net中treeView控件如何从数据库中取值????(利用三层)
- 服务器 树 tree 显示问题 20分求解答
- 为什么动态加载的用户控件中的表单 提交后接受不到参数????
- 如何在datagrid里的<columns>里,把 HeaderText="序号" 这个地方换成一个Dropdownlist
- 急切请教Session问题
- 嵌套查询问题??(答完马上解帖)!!!!!!!!!!!谢谢各位了
- asp代码转成c#版本的
- 搜索关键字的颜色问题
- 用vs2005 就提示 [包加载失败未能正确加载包Miscrosoft.visualStudio.testCaseMamagement.、……可以使用devenv/resetskippkge重新加载]
Response.Write(newID);
this.GridView1.EditIndex = -1;
this.bintNews();
报错 :未将对象引用设置到对象的实例。
我的问题和你的一样啊,我是做一个gridview,然后再页面上添加了一个按钮,要实现的功能是双击进行整行
编辑,点击按钮完成更新,但现在的问题就是去不到新值,更新不了。大侠,助人为乐,请问你是怎么解决的?