批量更新GridView中选定的值的方法

 1for (int i = 0; i <= CartGrid.Rows.Count - 1; i++
 2        {           
 3            
 4            int id = 0, quantity = 0;
 5
 6            HiddenField hdId = (HiddenField)CartGrid.Rows[i].FindControl("hdId");
 7            if (hdId != null
 8            {
 9                id = Convert.ToInt32(hdId.Value);
10            }

11
12            TextBox tb = (TextBox)CartGrid.Rows[i].FindControl("txtQuantity");
13            if (tb != null
14            {
15                quantity = Convert.ToInt32(tb.Text);
16            }

17
18            if (Profile.ShoppingCart == null)
19            {
20                Profile.ShoppingCart = new ShoppingCart();
21            }

22
23            Profile.ShoppingCart.UpdateItem(id, quantity);
24        }
posted @ 2007-04-29 16:17  海底的鱼  阅读(291)  评论(0)    收藏  举报