Exemplo n.º 1
0
 //populate the project drop down by user id
 public void LoadProject()
 {
     da = new SqlDataAdapter("Select p.ProjectId, ProjectName from Projects p inner join UserProject up on p.projectId = up.projectId where UserId = " + user_id, con);
     dt = new DataTable();
     da.Fill(dt);
     ProjectDropDownList.DataSource     = dt;
     ProjectDropDownList.DataTextField  = "ProjectName";
     ProjectDropDownList.DataValueField = "ProjectId";
     ProjectDropDownList.DataBind();
 }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            user_id = Request.QueryString["id"];

            //populate project drop down by user id
            if (!IsPostBack)
            {
                da = new SqlDataAdapter("Select p.ProjectId, ProjectName from Projects p inner join UserProject up on p.projectId = up.projectId where UserId = " + user_id, con);
                dt = new DataTable();
                da.Fill(dt);
                ProjectDropDownList.DataSource     = dt;
                ProjectDropDownList.DataTextField  = "ProjectName";
                ProjectDropDownList.DataValueField = "ProjectId";
                ProjectDropDownList.DataBind();
            }
        }
 public void ClientDropDown()
 {
     using (SqlConnection connection = new SqlConnection(con))
     {
         SqlCommand cmd = new SqlCommand("DisplayProject", connection);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@CId", ClientDropDownList.SelectedValue);
         connection.Open();
         SqlDataReader rdr = cmd.ExecuteReader();
         ProjectDropDownList.DataSource     = rdr;
         ProjectDropDownList.DataValueField = "PId";
         ProjectDropDownList.DataTextField  = "PName";
         ProjectDropDownList.DataBind();
         ListItem list = new ListItem("--Select--", "-1");
         ProjectDropDownList.Items.Insert(0, list);
     }
 }