protected void GridView2_RowUpdated(object sender, GridViewUpdatedEventArgs e)
{
int id = Convert.ToInt32(GridView2.Rows[e.AffectedRows].Cells[0].Text);
string bname = GridView2.Rows[e.AffectedRows].Cells[1].Text;
string bauthor = GridView2.Rows[e.AffectedRows].Cells[2].Text;
string bprice = GridView2.Rows[e.AffectedRows].Cells[3].Text;
string url="Update.aspx?bname="+Server.UrlEncode(bname)+"&bauthor="+Server.UrlEncode(bauthor)+"&bprice="+Server.UrlEncode(bprice)+"&bid="+Server.UrlEncode(id.ToString());
Response.Redirect(url);
}
为什么更新始终获取第一行
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
1条回答 默认 最新
- threenewbee 2016-06-21 13:01关注
e.AffectedRows,这个不是更新行的下标。
参考:http://www.cnblogs.com/SkySoot/archive/2012/08/10/2632153.html
protected void detailsEditing_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e) { if (e.AffectedRows == 0) { e.KeepInEditMode = true; // 保持在编辑模式 detailsEditing.DataBind(); // 重新绑定最新的数据 // 把先前更新失败的用户编辑的值重新放回文本框 // 这些原本要保存的值被放置在 e.NewValues 集合中 TextBox txt; txt = detailsEditing.Rows[1].Cells[1].Controls[0] as TextBox; txt.Text = e.NewValues["CompanyName"].ToString(); txt = detailsEditing.Rows[2].Cells[1].Controls[0] as TextBox; txt.Text = e.NewValues["Phone"].ToString(); errorPanel.Visible = true; } }
另外提醒lz如果问题解决请及时采纳。
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥50 有数据,怎么建立模型求影响全要素生产率的因素
- ¥50 有数据,怎么用matlab求全要素生产率
- ¥15 TI的insta-spin例程
- ¥15 完成下列问题完成下列问题
- ¥15 C#算法问题, 不知道怎么处理这个数据的转换
- ¥15 YoloV5 第三方库的版本对照问题
- ¥15 请完成下列相关问题!
- ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
- ¥15 求daily translation(DT)偏差订正方法的代码
- ¥15 js调用html页面需要隐藏某个按钮