Exemplo n.º 1
0
        protected void ddlDataBind()
        {
            DataTable dt = ProjectCreateInfo.getProjectLevel();

            ddlProjectLevel.DataSource     = dt;
            ddlProjectLevel.DataTextField  = "ProjectLevelName";
            ddlProjectLevel.DataValueField = "ProjectLevelId";
            DataRow row = dt.NewRow();

            row["ProjectLevelName"] = "请选择项目级别";
            dt.Rows.InsertAt(row, 0);
            ddlProjectLevel.DataBind();

            DataTable dt1 = ProjectCreateInfo.getProjectType();

            ddlProjectType.DataSource     = dt1;
            ddlProjectType.DataTextField  = "ProjectTypeName";
            ddlProjectType.DataValueField = "ProjectTypeId";
            DataRow row1 = dt1.NewRow();

            row1["ProjectTypeName"] = "请选择项目类别";
            dt1.Rows.InsertAt(row1, 0);
            ddlProjectType.DataBind();

            DataTable dt2 = ClientInfo.getClientList();

            ddlClient.DataSource     = dt2;
            ddlClient.DataTextField  = "ClientName";
            ddlClient.DataValueField = "ClientId";
            DataRow row2 = dt2.NewRow();

            row2["ClientName"] = "请选择客户名称";
            dt2.Rows.InsertAt(row2, 0);
            ddlClient.DataBind();
        }
Exemplo n.º 2
0
        protected void gvProject_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //鼠标移动到每项时颜色交替效果
                e.Row.Attributes.Add("onmouseover", "e=this.style.backgroundColor; this.style.backgroundColor='#c1ebff'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=e");

                //设置悬浮鼠标指针形状为"小手"
                e.Row.Attributes["style"] = "Cursor:hand";


                if (!Convert.IsDBNull(gvProject.DataKeys[e.Row.RowIndex].Value))
                {
                    int projectid = Convert.ToInt32(gvProject.DataKeys[e.Row.RowIndex].Value);
                    MainProjectCreateInfo project = new MainProjectCreateInfo(projectid);

                    DropDownList ddlProjectLevel = e.Row.FindControl("ddlProjectLevel") as DropDownList;

                    if (ddlProjectLevel != null)
                    {
                        DataTable dt = ProjectCreateInfo.getProjectLevel();
                        ddlProjectLevel.DataSource     = dt;
                        ddlProjectLevel.DataTextField  = "ProjectLevelName";
                        ddlProjectLevel.DataValueField = "ProjectLevelId";
                        ddlProjectLevel.DataBind();
                        ddlProjectLevel.SelectedValue = project.ProjectLevelId.ToString();
                    }

                    DropDownList ddlProjectType = e.Row.FindControl("ddlProjectType") as DropDownList;

                    if (ddlProjectType != null)
                    {
                        DataTable dt = ProjectCreateInfo.getProjectType();
                        ddlProjectType.DataSource     = dt;
                        ddlProjectType.DataTextField  = "ProjectTypeName";
                        ddlProjectType.DataValueField = "ProjectTypeId";
                        ddlProjectType.DataBind();
                        ddlProjectType.SelectedValue = project.ProjectTypeId.ToString();
                    }

                    DropDownList ddlClient = e.Row.FindControl("ddlClient") as DropDownList;
                    if (ddlClient != null)
                    {
                        DataTable dt = ClientInfo.getClientList();
                        ddlClient.DataSource     = dt;
                        ddlClient.DataTextField  = "ClientName";
                        ddlClient.DataValueField = "ClientValue";
                        ddlClient.DataBind();
                        ddlClient.SelectedValue = project.ClientId.ToString();
                    }
                }
            }
        }