gridview单击一行取值事件

        protected void gv_KsrList_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (!ShowMaxScore)
                {
                    KSR ksr = null;
                    if (!string.IsNullOrEmpty(e.Row.Cells[0].Text))
                    {
                        ksr = KSRService.GetKsrById(Convert.ToDecimal(e.Row.Cells[0].Text.Trim()));
                    }
                    if (ksr != null)
                    {
                        if (SQYHService.GetYHXM(ksr.YHDM) != null)
                            e.Row.Cells[2].Text = SQYHService.GetYHXM(ksr.YHDM).XM;
                        if (SQYHService.GetSQMC(ksr.SQID) != null)
                            e.Row.Cells[3].Text = SQYHService.GetSQMC(ksr.SQID).SQMC;
                    }

                    string adminDm = System.Configuration.ConfigurationManager.AppSettings["AdminDM"];
                    if (!string.IsNullOrEmpty(adminDm) && adminDm.IndexOf(sqyh.YHDM) != -1)
                    {
                        e.Row.Cells[7].Text = string.Format("<a href=\"showExam.aspx?paperId={0}\">查看试卷</a>", e.Row.Cells[0].Text.Trim());
                        //e.Row.Cells[7].Text += string.Format("<a href=\"del.aspx?id={0}&jgdm={1}&yhdm={2}\" onclick=\"return confirm('确定删除吗?删除之后不可恢复!!');\">删除</a>", e.Row.Cells[0].Text.Trim(), jgdm, yhdm);
                    }
                    else
                    {
                        e.Row.Cells[7].Text = "----";
                    }
                }
                else
                {
                    e.Row.Cells[0].Text = "----";
                    e.Row.Cells[3].Text = "----";
                    e.Row.Cells[4].Text = "----";
                    e.Row.Cells[7].Text = "----";

                    if (SQYHService.GetYHXM(e.Row.Cells[1].Text.Trim()) != null)
                        e.Row.Cells[2].Text = SQYHService.GetYHXM(e.Row.Cells[1].Text.Trim()).XM;
                    else
                        e.Row.Cells[2].Text = "----";
                }
            }
        }

posted on 2008-07-29 08:32  EricGu  阅读(558)  评论(0编辑  收藏  举报

导航