In LINQ Project: Not able to Hide and Show Controls [modified]
-
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
-
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
Remove the try-catch blocks - if an exception occurs you won't see it - that might be the cause
'Howard
-
Remove the try-catch blocks - if an exception occurs you won't see it - that might be the cause
'Howard
Thanks for the reply. I have remove the try catch but its not working ... I dont know why... Please help me... Thanks again ...