如题,GridView的onrowdatabound方法中多次连接数据库很快会造成连接满的情况,进而造成满查询,或者执行sql存储过程失败,导致程序不能正常运行
各位csdn高手们有没有什么方法可以防止这种情况??
或者说有没有什么方法可以像onrowdatabound一样改变GridView中的状态付源码protected void gv_Task_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            GridViewRow gvr = e.Row;
            if (gvr.RowIndex >= 0)
            {
                String TaskId = gvr.Cells[0].Text;
                gvr.Cells[5].Text = GetIsUseTestNumberString(gvr.Cells[5].Text);
                gvr.Cells[6].Text = GetIsUseTestNumberString(gvr.Cells[6].Text);
                HyperLink SF = (HyperLink)e.Row.Cells[9].Controls[0];
                SF.ToolTip = "群发任务发送的省份";
                Button btnStop = gvr.FindControl("btnStop") as Button;
                ImageButton ibtnDelete = gvr.FindControl("ibtnDelete") as ImageButton;                if (!ChackTime(gvr.Cells[0].Text))
                {
                    HyperLink hlf = (HyperLink)e.Row.Cells[10].Controls[0];
                    hlf.NavigateUrl = "SgsTaskTimeList.aspx?TaskId=" + TaskId + "";
                    hlf.Text = "未赋时段";
                    hlf.Font.Bold = true;
                    hlf.ToolTip = "未赋时段任务无法开始发送";
                    //hlf.BackColor = System.Drawing.Color.Red;//背景
                    //hlf.BorderColor = System.Drawing.Color.Blue;//边框
                    hlf.ForeColor = System.Drawing.Color.Red;//文字                }
                else
                {
                    HyperLink hl = (HyperLink)e.Row.Cells[10].Controls[0];
                    hl.ToolTip = "任务在时段内才发送";                }
                switch (gvr.Cells[7].Text)
                {
                    //case "1":
                    //    HyperLink ZT = (HyperLink)e.Row.Cells[7].Controls[0];
                    //    break;
                    case "3":
                        btnStop.Text = "重新启动";
                        btnStop.ToolTip = "重启该短信群发任务";
                        btnStop.OnClientClick = "return confirm('确定重新启动该短信群发任务吗?')";
                        break;
                    case "2":
                        ibtnDelete.Enabled = false;
                        btnStop.Enabled = false;
                        break;
                    case "4":
                        ibtnDelete.Enabled = false;
                        btnStop.Enabled = false;
                        break;
                    default:
                        break;
                }
                gvr.Cells[7].Text = GetTaskStatusString(gvr.Cells[7].Text);
                //这段调用数据库的代码总是导致问题出现sql已经不能优化了
                if (gvr.Cells[7].Text.Equals("执行中"))
                {
                    if (SgsWebBll.CheckAllProvinceTask(Int32.Parse(gvr.Cells[0].Text)) == 0)
                    {
                        gvr.Cells[7].Text = "暂停中";
                        gvr.Cells[7].ForeColor = System.Drawing.Color.Red;
                    }
                }
            }