Exemple #1
0
        protected void GvLookupPegawai_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Session["Triger"] != null)
            {
                if (Session["Triger"].ToString() == "txtCol2Edit")
                {
                    ((TextBox)GvUsers.Rows[GvUsers.EditIndex].Cells[2].FindControl("txtCol2Edit")).Text = ((Label)GvLookupPegawai.SelectedRow.Cells[0].FindControl("Label1")).Text;
                    ((Label)GvUsers.Rows[GvUsers.EditIndex].Cells[3].FindControl("lblCol3Edit")).Text   = ((Label)GvLookupPegawai.SelectedRow.Cells[2].FindControl("Label2")).Text;
                }
                else if (Session["Triger"].ToString() == "txtCol2Footer")
                {
                    ((TextBox)GvUsers.FooterRow.Cells[2].FindControl("txtCol2Footer")).Text = ((Label)GvLookupPegawai.SelectedRow.Cells[0].FindControl("Label1")).Text;
                    ((Label)GvUsers.FooterRow.Cells[3].FindControl("lblCol3Footer")).Text   = ((Label)GvLookupPegawai.SelectedRow.Cells[2].FindControl("Label2")).Text;
                }
                else if (Session["Triger"].ToString() == "txtCol2FormView")
                {
                    ((TextBox)FvUsers.FindControl("txtCol2FormView")).Text = ((Label)GvLookupPegawai.SelectedRow.Cells[0].FindControl("Label1")).Text;
                    ((Label)FvUsers.FindControl("lblCol3FormView")).Text   = ((Label)GvLookupPegawai.SelectedRow.Cells[2].FindControl("Label2")).Text;
                }
                Session.Remove("Triger");
            }

            setInitialLookupState();
            UpdatePanel1.Update();
        }
Exemple #2
0
        protected void dsUsers_Inserting(object sender, System.Web.UI.WebControls.SqlDataSourceCommandEventArgs e)
        {
            //jika tambah data dilakukan melalui gridview/data pada gridview tidak kosong,
            //maka parameter-parameter datasource didapat dr control-control yg ada di footerrow
            //jika tambah data dilakukan melalui FormView,
            //maka parameter-parameter datasource didapat secara otomatis
            //dr control-control yang sudah melakukan binding yg terdapat di formView
            TextBox userName;

            if (GvUsers.Rows.Count > 0)
            {
                userName = (TextBox)(GvUsers.FooterRow.FindControl("txtCol0Footer"));
                DropDownList level = (DropDownList)(GvUsers.FooterRow.FindControl("ddlCol1Footer"));
                TextBox      NIP   = (TextBox)(GvUsers.FooterRow.FindControl("txtCol2Footer"));

                e.Command.Parameters["@USERNAME"].Value   = userName.Text;
                e.Command.Parameters["@KODE_LEVEL"].Value = level.SelectedValue;
                e.Command.Parameters["@NIP"].Value        = NIP.Text;
            }
            else
            {
                userName = (TextBox)(FvUsers.FindControl("txtCol0FormView"));
            }

            string pass = common.CreateRandomPassword(8);

            e.Command.Parameters["@PASSW"].Value = common.cekuser(pass);
            ExceptionDetails.Text    = "User Name: " + userName.Text + " Password: " + pass;
            ExceptionDetails.Visible = true;
        }
Exemple #3
0
        protected void txtCol2FormView_TextChanged(object sender, EventArgs e)
        {
            TextBox txtNIP  = (TextBox)FvUsers.FindControl("txtCol2FormView");
            Label   lblNama = (Label)FvUsers.FindControl("lblCol3FormView");

            setNama(txtNIP, lblNama);
        }
Exemple #4
0
 //fungsi: menghandle ketika tambah data akan dilakukan
 protected void lblTambah_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         //Seleksi apakah data kosong atau tidak,
         //jika kosong maka proses tambah data dilakukan melalui formView,
         //jika tidak kosong maka proses tambah data dilakukan melalui GridView,
         if (GvUsers.Rows.Count > 0)
         {
             //Data tidak kosong
             sendToLastPage     = true;
             GvUsers.ShowFooter = true;
             this.ScriptManager1.SetFocus(GvUsers.FooterRow.Cells[0].FindControl("txtCol0Footer").ClientID);
         }
         else
         {
             //Data Kosong
             FvUsers.DefaultMode = FormViewMode.Insert;
             FvUsers.DataBind();    //diperlukan jika didalam formview terdapat dropdownlist
             this.ScriptManager1.SetFocus(FvUsers.FindControl("txtCol0FormView"));
         }
     }
 }