更改多条记录问题

zlxsdn 2009-04-25 06:06:08
c#问题 在datagrid 中有checkbox 当全选或多选时 要更新选中的记录 我知要用循环做 要怎么做法请详细说下 谢斻 越详细越好 100分捧上 少了再加 谢谢
...全文
61 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
sushou2009 2009-04-25
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 ws_hgo 的回复:]
GridView的和DataGrid差不多
搞不清
现在怎么还要用2003

C# code protected void Button1_Click(object sender, EventArgs e)
{
//批量删除
int intCount = this.GridView1.Rows.Count;
for (int i = 0; i < intCount; i++)
{
CheckBox CheckSingle = this.GridView1.Rows[i].Cells[0].FindControl("CheckSingle") as CheckBox;
if (CheckSingle…
[/Quote]
UP~
zealot1021 2009-04-25
  • 打赏
  • 举报
回复
实在不行就从dataGrid中取值再封装一个dataTable,用dataTable再执行更新操作,笨办法
liuyeede 2009-04-25
  • 打赏
  • 举报
回复
zlxsdn 2009-04-25
  • 打赏
  • 举报
回复
要求用datagrid 实现 datagrid没有row属性得不到行的ID
ws_hgo 2009-04-25
  • 打赏
  • 举报
回复
GridView的和DataGrid差不多
搞不清
现在怎么还要用2003
    protected void Button1_Click(object sender, EventArgs e)
{
//批量删除
int intCount = this.GridView1.Rows.Count;
for (int i = 0; i < intCount; i++)
{
CheckBox CheckSingle = this.GridView1.Rows[i].Cells[0].FindControl("CheckSingle") as CheckBox;
if (CheckSingle.Checked)
{
int CardID = Convert.ToInt32(this.GridView1.Rows[i].Cells[1].Text);
Card Cardinfo = new Card();
Cardinfo.CID = CardID;
Card.DeleteCard(Cardinfo);
}
}
BindList();
this.GridView1.DataBind();
//this.GridView1.DataBind();
//GridView1.PageIndex = -1;
}
hecong875 2009-04-25
  • 打赏
  • 举报
回复
//后台
protected void btnNext_Click(object sender, EventArgs e)
{

gv//GridView ID
chbSelect// GridView 内 CheckBox ID

for (int i = 0; i < this.gv.Rows.Count; i++)
{
CheckBox chb = gv.Rows[i].FindControl("chbSelect") as CheckBox;
if (chb.Checked)
{
DataRow dr = list.Tables[0].Rows[i];
DataRow drForAdd = dtTmp.NewRow();
for (int j = 0; j < dr.ItemArray.Length; j++)
{
drForAdd[j] = dr.ItemArray[j];
}
dtTmp.Rows.Add(drForAdd);
}
}
}

110,535

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧