我DataGrid自定义了一按钮列,作用是点击后转到下个页面显示当列数据的详细内容
this.DataGrid1.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHandler(this.DataGrid1_View);private void DataGrid1_View(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{

Session["Key"] = e.Item.Cells[0].Text;
Response.Redirect("list_details.aspx");
}
但是现在它影响到了DataGrid1的翻页按钮,现在点击翻页就没效果了,请问该如何解决?
让DataGrid1_View事件不要影响到翻页按钮
我试过将ItemCommand换成其他Edit Update等几个Command,但是都不行

解决方案 »

  1.   

    用的datagrid自带的分页按钮
    this.DataGrid1.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.DataGrid1_PageIndexChanged);private void DataGrid1_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)  
    {
    this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
    DataSet da = new DataSet();
    this.SqlDataAdpter1.Fill( da,"1");
    this.DataGrid1.DataSource = da;
    this.DataGrid1.DataBind();
    }
      

  2.   

    换种思路,你是为了实现某种效果可以用imagebutton, button,他们有个属性叫commandname 取个名字,然后在后台的itemcommand命令中:if(commandname=""){Session["Key"] = e.Item.Cells[0].Text;
    Response.Redirect("list_details.aspx");
    }
    try it!
      

  3.   

    判断commandname,
    sub datagrid_itemcommand()if e.commandname=yourcommand then
        execute your clickcommand
    else
       exit sub
    end if
        continue to execute your clickcommandend sub这样判断之后,换页时,会检查出所点击的不是命令按钮就会退出itemcommand事件
    继续去执行pageindexchanged事件
      

  4.   

    翻页 排序 和按钮事件都属于CommandItem,给你的按钮的commandName 取个名区分一下,用commandName来判断执行的是按钮事件