---
title: "GridView如何更新批量数据和单条记录(downmoon)？"
author: "netxdiy"
date: "2007-12-14T13:44:00Z"
tags: []
slug: "gridview-downmoon"
draft: false
lastmod: "2012-09-27T11:31:37Z"
id: 1687110
url: "https://netxdiy.iteye.com/blog/1687110"
---

后台代码段

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif) Members #region Members  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected GridViewGVList;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public string PreUrl = Agronet.Common.Framework.Util.Globals.MemberUserPath + " Product " + @" / " ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected Agronet.Common.Framework.Util.Pagerpager;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected TextBoxtxtSearchTxt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected ButtonbtnSearch;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected HyperLinkcmdAdd;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected LinkButtoncmdDel;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected LinkButtoncmdRecommend;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected LinkButtoncmdUnPublish;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected TextBoxtxtWords;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected DropDownListddlType;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected LabelTradeTypeID;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected LabelNoResult;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) private int \_page = 1 ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public int \_sort = 0 ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) /\*\*/ /// &lt;summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) /// 关键字  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) /// downmoon2007年12月12日  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) /// &lt;/summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) private string \_word  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) get  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) object o = ViewState\[ " strWords " ];  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) return (o == null ) ? "" :o.ToString();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) set  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) ViewState\[ " strWords " ] = value;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) // 审核状态  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) public short CheckState  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) get  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) object o = ViewState\[ " CheckState " ];  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) return SQLParser.ShortParse(o);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) set ... {ViewState\[ " CheckState " ] = value;}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif) Events #region Events  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected override void OnLoad(EventArgse)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) base .OnLoad(e);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) Check #region Check  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) CheckSiteUser();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) initPage #region initPage  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) \_page = SQLParser.IntParse(Page.Request.QueryString\[ " page " ]);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) \_word = SQLParser.StringParse(Page.Request.QueryString\[ " word " ]);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) CheckState = SQLParser.ShortParse(Page.Request.QueryString\[ " st " ]);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if (txtSearchTxt != null )  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) txtSearchTxt.Attributes.Add( " maxlength " , " 20 " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) txtSearchTxt.Text = \_word;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if ( this .ddlType != null )  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) this .ddlType.SelectedValue = this .CheckState.ToString();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) this .ddlType.SelectedIndexChanged += new EventHandler(ddlType\_SelectedIndexChanged);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) if (cmdAdd != null ) ... {cmdAdd.NavigateUrl = PreUrl + " Insert.aspx " ;}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) if (cmdDel != null ) ... {cmdDel.Click += new EventHandler(cmdDel\_Click);}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) if (cmdRecommend != null ) ... {cmdRecommend.Click += new EventHandler(cmdRecommend\_Click);}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) if (cmdUnPublish != null ) ... {cmdUnPublish.Click += new EventHandler(cmdUnPublish\_Click);}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) pager.PageIndex = \_page;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) pager.PageSize = Agronet.Common.Framework.Util.Globals.PageSize;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if (GVList != null )  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) GVList.RowDataBound += new GridViewRowEventHandler(GVList\_RowDataBound);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) GVList.RowCommand += new GridViewCommandEventHandler(GVList\_RowCommand);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) GVList.RowUpdating += new GridViewUpdateEventHandler(GVList\_RowUpdating);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) if (NoResult != null ) ... {NoResult.Text = GetCurStateByID(CheckState) + " 列表 " ;}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) if (btnSearch != null ) ... {btnSearch.Click += new EventHandler(btnSearch\_Click);}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) BindList #region BindList  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if ( ! IsPostBack)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) BindList();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) pager.UrlFormat = PreUrl + " ?page={0}&sort=0&dvid=2&word= " + \_word + " &st= " + CheckState.ToString();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) Serarch #region Serarch  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) private void btnSearch\_Click( object sender,EventArgse)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) string strurl = PreUrl + " ?dvid=2&sort=0&st={0}&word={1} " ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) this .CheckState = SQLParser.ShortParse( this .ddlType.SelectedItem.Value);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) strurl = string .Format(strurl,CheckState.ToString(),txtSearchTxt.Text.Trim());  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) PageLocation(strurl);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) ddlType #region ddlType  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) private void ddlType\_SelectedIndexChanged( object sender,EventArgse)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if ( this .ddlType != null && ddlType.SelectedValue.Trim() != "" )  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) this .CheckState = SQLParser.ShortParse( this .ddlType.SelectedItem.Value);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) string strurl = PreUrl + " ?dvid=2&page=1&st= " + CheckState.ToString() + " &word= " + this .txtSearchTxt.Text.Trim();;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) PageLocation(strurl);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected void cmdDel\_Click( object sender,EventArgse)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) 执行批量操作 #region 执行批量操作  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) UpdateMultiRecordsByWhere(pager.PageSize, - 4 , 1 );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) private void cmdUnPublish\_Click( object sender,EventArgse)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) 执行批量操作 #region 执行批量操作  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) UpdateMultiRecordsByWhere(pager.PageSize, - 2 , 1 );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) private void GVList\_RowCommand( object sender,GridViewCommandEventArgse)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) 执行批量操作 #region 执行批量操作  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if (e.CommandName == " Update " )  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) try  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) int days = 0 ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) if (muser.ClientClass &gt; 0 ) ... {days = Globals.ProductinfoUpdatePerDays;}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) long pid = SQLParser.LongParse(GVList.DataKeys\[SQLParser.IntParse(e.CommandArgument)].Value);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) // GridViewa=(GridView)sender;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if (pid &gt; 0 )  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) int retValue = Agronet.Product.Framework.Data.DataDTOProvider.ProducyUpdateModifyTime(pid,days,muser.LoginID);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) switch (retValue)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) case - 1 :  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) Debug( " 产品更新失败，原因：产品未通过审核！ " , " Error " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) break ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) case 0 :  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) Debug( " 产品更新失败，原因：未知！ " , " Error " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) break ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) case 1 :  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) Index #region Index  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) Debug( " 产品更新成功！ " , " Succeed " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) break ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) case 2 :  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) Debug( " 尊敬用户 " + user.LoginID + @" 您好， 您选择的产品暂时还不能被更新,原因：单位时间内更新过与频繁，二十分钟之内不能连续更新！ " , " Error " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) break ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) default :  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) break ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) catch (Exceptionex)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) return ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) private void GVList\_RowUpdating( object sender,GridViewUpdateEventArgse)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) // BindList();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) private void cmdRecommend\_Click( object sender,EventArgse)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) 执行批量操作 #region 执行批量操作  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) UpdateMultiRecordsByWhere(pager.PageSize, 1 , 2 );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) protected void GVList\_RowDataBound( object sender,GridViewRowEventArgse)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if (e.Row.RowType == DataControlRowType.DataRow)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) HyperLinkcmdMod = (HyperLink)e.Row.FindControl( " cmdMod " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) if (cmdMod != null ) ... {cmdMod.NavigateUrl = PreUrl + " Modify.aspx?dvid=2&PKID= " + DataBinder.Eval(e.Row.DataItem, " P\_ID " );}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) LinkButtonlbUpdate = (LinkButton)e.Row.FindControl( " cmdUpdate " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) if (lbUpdate != null ) ... {lbUpdate.CommandArgument = e.Row.RowIndex.ToString();}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif) Methods #region Methods  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) BindList #region BindList  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) private void BindList()  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) string strWhere = string .Empty;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) strWhere = " (LoginID=' " + muser.LoginID + " ') " ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) Agronet.Product.Framework.Components.ProductCollectionsc = Agronet.Product.Framework.Data.DataDTOProvider.GetProductReturnCollection(\_word.Trim(),strWhere,pager.PageIndex,pager.PageSize,\_sort,CheckState);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) this .GVList.DataSource = sc;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) this .GVList.DataBind();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if (sc.MaxItems &gt; 0 )  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {pager.ItemCount = sc.MaxItems;}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) else  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) pager.Visible = false ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) this .NoResult.Text = " 无符合条件的记录! " ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) MultipleRecordUpdateMethod #region MultipleRecordUpdateMethod  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) private void UpdateMultiRecordsByWhere( int mCount, short mState, short updateType)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) Check #region Check  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) CheckSiteUser();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif) 执行批量操作 #region 执行批量操作  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) try  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) StringBuildersb = new StringBuilder();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) string strTemp = string .Empty;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) string PKName = string .Empty;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) int tempCount = 0 ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) if (GVList == null || GVList.Rows.Count == 0 ) ... { return ;}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) PKName = GVList.DataKeyNames\[ 0 ].ToString();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) sb.Append( " where " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) sb.Append( " LoginID=' " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) sb.Append(muser.LoginID);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) sb.Append( " 'AND " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) sb.Append(PKName);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) sb.Append( " in( " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) for ( int i = 0 ;i &lt; GVList.Rows.Count;i ++ )  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) CheckBoxchk = (CheckBox)GVList.Rows\[i].FindControl( " chkDelServer " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if (chk != null && chk.Checked)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) sb.Append(GVList.DataKeys\[i].Value.ToString());  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) sb.Append( " , " );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) tempCount ++ ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if (tempCount == 0 ) return ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) if (tempCount &gt; mCount) ... {Debug( " 超出批量操作的最大允许数量! " , this .ClientID, true ); return ;}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) strTemp = sb.ToString();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) if (strTemp.EndsWith( " , " )) ... {strTemp = strTemp.Remove(strTemp.Length - 1 );}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) strTemp += " ) " ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if (updateType == 1 )  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) Agronet.Product.Framework.Data.DataDTOProvider.ProductUpdateStatusByWhere(strTemp,mState,muser.LoginID);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) else  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) Agronet.Product.Framework.Data.DataDTOProvider.ProductUpdateRecommendStatusByWhere(strTemp,mState,muser.LoginID);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) BindList();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) catch (Exceptionex)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) Debug(ex.Message, this .ClientID, true );  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) return ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) #endregion  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif) #endregion

前台html

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)&lt; script language ="JavaScript" &gt; ...  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) &lt;!--  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) function CheckAll(val)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) for ( var i = 0 ;i &lt; document.forms\[ 0 ].elements.length;i ++ )  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) var e = document.forms\[ 0 ].elements\[i];  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) if (e.Type = " checkbox " && e.name != " \_ctl2:\_ctl0:radioSortDesc " )  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) e.checked = val;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif) }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) // --&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ script &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; table width ="95%" border ="0" cellpadding ="0" cellspacing ="0" align ="center" &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; tr &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; td height ="25" align ="right" bgcolor ="#EFEFEF" class ="tab\_font\_right" &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; strong &gt; 产品搜索 &lt;/ strong &gt; ：  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:TextBox ID ="txtSearchTxt" runat ="server" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:Button ID ="btnSearch" runat ="server" Text ="搜索" &gt;&lt;/ asp:Button &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 转到  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:DropDownList ID ="ddlType" runat ="server" CssClass ="maintext" AutoPostBack ="True" &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:ListItem Value ="10000" &gt; 所有产品 &lt;/ asp:ListItem &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:ListItem Value ="2" &gt; 已推荐 &lt;/ asp:ListItem &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:ListItem Value ="1" &gt; 当前发布 &lt;/ asp:ListItem &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:ListItem Value ="0" &gt; 等待审核 &lt;/ asp:ListItem &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:ListItem Value ="-1" &gt; 未通过审核 &lt;/ asp:ListItem &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:ListItem Value ="-2" &gt; 未发布 &lt;/ asp:ListItem &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ asp:DropDownList &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ td &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ tr &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ table &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; table width ="95%" border ="0" align ="center" cellpadding ="0" cellspacing ="1" &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; tr &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; td &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:GridView ID ="GVList" runat ="server" ShowFooter ="true" AutoGenerateColumns ="False"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) BorderStyle ="Solid" BorderColor ="#ffffff" GridLines ="Horizontal" CellSpacing ="1"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) Width ="100%" HorizontalAlign ="NotSet" BorderWidth ="0px" EnableViewState ="true"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) DataKeyNames ="P\_ID" &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderStyle CssClass ="InfoHeaderText" ForeColor ="#000000" HorizontalAlign ="center"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) Height ="22px" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; AlternatingRowStyle BackColor ="#f7f7f7" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; RowStyle HorizontalAlign ="center" Height ="20px" BackColor ="#E3EAEB" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; SelectedRowStyle BackColor ="#C5BBAF" Font-Bold ="True" ForeColor ="#333333" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; Columns &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderStyle Width ="60px" BackColor ="#1C5E55" ForeColor ="White" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) 编号 &lt;/ HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:Label ID ="PKID" Text ='&lt;%# DataBinder.Eval(Container.DataItem,"P\_ID")% &gt; 'runat="server"/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:TemplateField Visible ="False" &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:Label ID ="Image\_Head" runat ="server" Text ="产品图片" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderStyle Width ="120" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:HyperLink ID ="P\_SmallImage" runat ="server" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &nbsp; 产品名称 &lt;/ HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; ItemStyle HorizontalAlign ="left" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderStyle HorizontalAlign ="Left" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &nbsp; · &lt; asp:Label ID ="P\_Name" Text ='&lt;%# DataBinder.Eval(Container.DataItem,"P\_Name")% &gt; '  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) runat="Server"/&gt; &lt; img src ='&lt;%# "/Resource/images/Check"+DataBinder.Eval(Container,"DataItem.CurState")+".gif"% &gt; '/&gt; &lt;/ ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:BoundField DataField ="ModTime" HeaderText ="修改时间" DataFormatString ="{0:yyyy-MM-ddHH:mm}"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) HtmlEncode ="false" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:BoundField DataField ="ModUser" HeaderText ="修改者" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) 状态 &lt;/ HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:Label ID ="CurState" Text ='&lt;%# GetCurStateByID(DataBinder.Eval(Container.DataItem,"CurState"))% &gt; '  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) runat="Server"/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderStyle Width ="60px" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) 编辑 &lt;/ HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:HyperLink ID ="cmdMod" CssClass ="ElementNavigation" Text ="编辑" runat ="server" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderStyle Width ="60px" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) 更新 &lt;/ HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:LinkButton ID ="cmdUpdate" CommandName ="Update" CssClass ="ElementNavigation" Text ="快速更新" runat ="server" OnClientClick ="returnconfirm('您确认快速更新该记录吗?');" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderStyle Width ="40px" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; input type ="checkbox" name ="allbox" value ="CheckAll" onclick ="CheckAll(allbox.checked);" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ HeaderTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:CheckBox ID ="chkDelServer" runat ="server" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ ItemTemplate &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ asp:TemplateField &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ Columns &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ asp:GridView &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ td &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ tr &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; tr &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; td align ="right" &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; asp:HyperLink ID ="cmdAdd" ForeColor ="Red" Text ="新增" CssClass ="ElementNavigation"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) runat ="server" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &nbsp;&nbsp; &lt; asp:LinkButton ID ="cmdRecommend" runat ="server" CssClass ="ElementNavigation"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) Text ="推荐" CommandName ="ReCommend" CausesValidation ="false" OnClientClick ="javascript:returnconfirm('确定推荐或(取消推荐)已选择的数据吗？')" &gt;&lt;/ asp:LinkButton &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &nbsp;&nbsp; &lt; asp:LinkButton ID ="cmdUnPublish" runat ="server" CssClass ="ElementNavigation"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) Text ="取消发布" CommandName ="UnPublish" CausesValidation ="false" OnClientClick ="javascript:returnconfirm('确定取消发布已选择的数据吗？')" &gt;&lt;/ asp:LinkButton &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &nbsp;&nbsp; &lt; asp:LinkButton ID ="cmdDel" ForeColor ="Red" Text ="删除" CssClass ="ElementNavigation"  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) CausesValidation ="false" runat ="server" CommandName ="Delete" OnClientClick ="javascript:returnconfirm('确定删除已选择的数据吗？')" /&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ td &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ tr &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; tr &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; td &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt; Agronet:Pager ID ="pager" runat ="server" CssClass ="Pager" LinkFormatActive ='&lt;a href ="{0}" class ="Current" &gt; {1} &lt;/ a &gt; '  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) PrefixText="页码:"UseSpacer="False"/&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ td &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ tr &gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) &lt;/ table &gt;

值处注意的是：  
必须添加这个事件，即使它什么也不干

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif) private void GVList\_RowUpdating( object sender,GridViewUpdateEventArgse)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif) ... {  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif) // BindList();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif) }

否则会提示“未处理的RowUpdating事件”