绑定数据时,给按钮添加主键值参数
Code
protected void gvwCaseList_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton btnSelect = (LinkButton)e.Row.FindControl("lkbFor");
btnSelect.CommandArgument = this.gvwCaseList.DataKeys[e.Row.RowIndex].Value.ToString();
LinkButton btnEdit = (LinkButton)e.Row.FindControl("lkbEdit");
btnEdit.CommandArgument = this.gvwCaseList.DataKeys[e.Row.RowIndex].Value.ToString();
LinkButton btnDelete = (LinkButton)e.Row.FindControl("lkbDelete");
btnDelete.CommandArgument = this.gvwCaseList.DataKeys[e.Row.RowIndex].Value.ToString();
LinkButton btnSee = (LinkButton)e.Row.FindControl("lkbSee");
btnSee.CommandArgument = this.gvwCaseList.DataKeys[e.Row.RowIndex].Value.ToString();
btnSee.Attributes.Add("onclick", "javascript:window.open('case_detail.aspx?caseid=" + btnSee.CommandArgument + "','','scrollbars=yes,status=no,width=1200,height=470')");
if (UserInfo.UserType == "02")
{
btnSelect.Visible = false;
btnEdit.Visible = false;
btnDelete.Visible = false;
}
}
}