protected void btnShowAll_Click(object sender, EventArgs e)
 {
     try
     {
         if (btnShowAll.Text == "Show All")
         {
             ObjUnit = new clsUnits();
             DataSet ds = ObjUnit.GetAllUnitsData();
             if (ds.Tables[0].Rows.Count != 0)
             {
                 grdUnit.DataSource = ds.Tables[0];
                 grdUnit.DataBind();
             }
             else
             {
                 grdUnit.EmptyDataText = "No Records Found to display.";
                 grdUnit.DataBind();
             }
             divUnit.Visible = true;
             btnShowAll.Text = "Close";
         }
         else if (btnShowAll.Text == "Close")
         {
             divUnit.Visible = false;
             btnShowAll.Text = "Show All";
         }
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
Exemple #2
0
 private void BindUnitsData()
 {
     try
     {
         clsUnits objUnit = new clsUnits();
         DataSet  ds      = objUnit.GetAllUnitsData();
         if (ds.Tables[0].Rows.Count != 0)
         {
             ddlUnitId.DataSource     = ds.Tables[0];
             ddlUnitId.DataTextField  = "UnitName";
             ddlUnitId.DataValueField = "UnitId";
             ddlUnitId.DataBind();
         }
         ddlUnitId.Items.Insert(0, "--Select One--");
     }
     catch (Exception)
     {
         lblMsg.Text = "Run Time Exception";
     }
 }