Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. In LINQ Project: Not able to Hide and Show Controls [modified]

In LINQ Project: Not able to Hide and Show Controls [modified]

Scheduled Pinned Locked Moved LINQ
csharpasp-netlinqhelp
3 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    varshavmane
    wrote on last edited by
    #1

    Hi All, I am using ASP.NET 2008 (C#) with LINQ. I have Page where I have 2 Textboxes, 2 labels, 1 button, 1 image button and 1 gridview. The problem is that I am hidding the button, 1 label and 1 textbox on Page load and when I select something in the other textbox and click on image button girdview is loaded and if there is no records in gridview then I have to show the hidden controls. Hidding is working fine but its not showing the controls. I dont know whats the problem. here is the code:

    protected void Page_Load(object sender, EventArgs e)
    {
    if (!IsPostBack)
    {
    btnSave.Visible = false;
    lblStageNumber.Visible = false;
    txtStageNumber.Visible = true;
    }
    }

    protected void ibtnGetDisease_Click(object sender, ImageClickEventArgs e)
    {
    try
    {
    BindGridView();
    }
    catch (Exception ex)
    {

            }
        }
    

    private void BindGridView()
    {
    try
    {
    var getGridData = from d in _datacontext.Diseases
    from s in _datacontext.Stages
    from ds in _datacontext.DiseaseStages
    where d.ID.Equals(ds.DiseaseID)
    && s.ID.Equals(ds.StageID)
    && d.Name.Equals(txtSelectDisease.Text.Trim())
    select new
    {
    DiseaseID = d.ID
    ,
    StageID = s.ID
    ,
    StageName = s.Name
    };

                grdDiseaseStage.DataSource = getGridData;
                grdDiseaseStage.DataBind();
    
                Int32 intRowCount = grdDiseaseStage.Rows.Count;
                if (intRowCount == 0)
                {
                    btnSave.Visible= true;
                    lblStageNumber.Visible = true;
                    txtStageNumber.Visible = false;
                }
            }
            catch (Exception ex)
            {
            }
        }
    

    Thanks in advance ...

    modified on Thursday, November 20, 2008 5:36 AM

    H 1 Reply Last reply
    0
    • V varshavmane

      Hi All, I am using ASP.NET 2008 (C#) with LINQ. I have Page where I have 2 Textboxes, 2 labels, 1 button, 1 image button and 1 gridview. The problem is that I am hidding the button, 1 label and 1 textbox on Page load and when I select something in the other textbox and click on image button girdview is loaded and if there is no records in gridview then I have to show the hidden controls. Hidding is working fine but its not showing the controls. I dont know whats the problem. here is the code:

      protected void Page_Load(object sender, EventArgs e)
      {
      if (!IsPostBack)
      {
      btnSave.Visible = false;
      lblStageNumber.Visible = false;
      txtStageNumber.Visible = true;
      }
      }

      protected void ibtnGetDisease_Click(object sender, ImageClickEventArgs e)
      {
      try
      {
      BindGridView();
      }
      catch (Exception ex)
      {

              }
          }
      

      private void BindGridView()
      {
      try
      {
      var getGridData = from d in _datacontext.Diseases
      from s in _datacontext.Stages
      from ds in _datacontext.DiseaseStages
      where d.ID.Equals(ds.DiseaseID)
      && s.ID.Equals(ds.StageID)
      && d.Name.Equals(txtSelectDisease.Text.Trim())
      select new
      {
      DiseaseID = d.ID
      ,
      StageID = s.ID
      ,
      StageName = s.Name
      };

                  grdDiseaseStage.DataSource = getGridData;
                  grdDiseaseStage.DataBind();
      
                  Int32 intRowCount = grdDiseaseStage.Rows.Count;
                  if (intRowCount == 0)
                  {
                      btnSave.Visible= true;
                      lblStageNumber.Visible = true;
                      txtStageNumber.Visible = false;
                  }
              }
              catch (Exception ex)
              {
              }
          }
      

      Thanks in advance ...

      modified on Thursday, November 20, 2008 5:36 AM

      H Offline
      H Offline
      Howard Richards
      wrote on last edited by
      #2

      Remove the try-catch blocks - if an exception occurs you won't see it - that might be the cause

      'Howard

      V 1 Reply Last reply
      0
      • H Howard Richards

        Remove the try-catch blocks - if an exception occurs you won't see it - that might be the cause

        'Howard

        V Offline
        V Offline
        varshavmane
        wrote on last edited by
        #3

        Thanks for the reply. I have remove the try catch but its not working ... I dont know why... Please help me... Thanks again ...

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups