我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,但是都不行
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,但是都不行
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();
}
Response.Redirect("list_details.aspx");
}
try it!
sub datagrid_itemcommand()if e.commandname=yourcommand then
execute your clickcommand
else
exit sub
end if
continue to execute your clickcommandend sub这样判断之后,换页时,会检查出所点击的不是命令按钮就会退出itemcommand事件
继续去执行pageindexchanged事件