Esempio n. 1
0
    private void BindViews(int?Threshold_Id = null)
    {
        DataSet ds = BLL_Tec_ErLog.Get_ErLogBookThresHold_EDIT(int.Parse(ViewState["VESSELID"].ToString()), UDFLib.ConvertIntegerToNull(lblLogId.Text), Threshold_Id);

        ds.Tables[0].Rows[0]["Vessel_Id"] = UDFLib.ConvertIntegerToNull(ViewState["VESSELID"]);

        if (Threshold_Id == null)
        {
            DDLVersion.DataSource     = ds.Tables[1];
            DDLVersion.DataTextField  = "Version";
            DDLVersion.DataValueField = "ID";
            DDLVersion.DataBind();

            if (ds.Tables[1].Rows.Count == 0)
            {
                DDLVersion.Enabled = false;
                DDLVersion.Items.Insert(0, new ListItem("-No Records found-", "0"));
            }
            else
            {
                DDLVersion.Enabled = true;
            }
        }


        if (ds.Tables[0].Rows.Count > 0)
        {
            ddlVesselMain.SelectedValue = ds.Tables[0].Rows[0]["Vessel_Id"].ToString();
            FormView1.DataSource        = ds.Tables[0];
            FormView1.DataBind();

            if (ds.Tables[0].Rows[0]["Active_Status"].ToString() == "0")
            {
                btnAddTo.Enabled = false;
                btnCopy.Enabled  = false;
                //  btnOK.Enabled = false;
                btnSave.Enabled = false;
            }
        }
        if (Convert.ToString(ds.Tables[0].Rows[0]["ID"]) != "")//if ds doesn't have rows throwing an error
        {
            DDLVersion.SelectedValue = ds.Tables[0].Rows[0]["ID"].ToString();
        }
    }