日期:2014-05-17  浏览次数:20565 次

怎样禁止gridview 换页的时候会触发RowCommand事件
gridview 换页的时候会触发RowCommand事件,导致GridViewRow索引超出范围

------解决方案--------------------
本帖最后由 net_lover 于 2011-07-29 09:39:55 编辑
protected void gvSubCate_RowCommand(object sender, GridViewCommandEventArgs e)
  {
    if (!e.CommandName.Equals("Page"))
    {
    int index = Convert.ToInt32(e.CommandArgument);
    GridViewRow row = gvSubCate.Rows[index];
    int id = Convert.ToInt32(row.Cells[0].Text);
    .......
    }

  }