J
Jason Huang
Hi,
In my ASPNET 2.0 C# Web form, I have a funciton BindGridView for binding
SqlDataSourceA to the GridView gvTestForm.
And in the end of the function, I would like to check if there are no rows
in the GridView then the control btnDetail is disabled.
However, this function doesn't work as what I pland.
The gvTestForm.Rows.Count respond last time's Row, not the current row count
in ths SqlDataSourceA.
What have I done wrong?
Thanks for help.
Jason
public void BindGridView()
{
this.m_strStartDate = this.ddlStartYear.SelectedItem.Text +
this.ddlStartMonth.SelectedItem.Text + this.ddlStartDay.SelectedItem.Text;
this.m_strEndDate = this.ddlEndYear.Text + this.ddlEndMonth.Text +
this.ddlEndDay.Text;
try
{
this.SqlDataSourceA.SelectParameters["prAcceptDateStart"].DefaultValue
= this.m_strStartDate;
this.SqlDataSourceA.SelectParameters["prAcceptDateEnd"].DefaultValue
= this.m_strEndDate;
this.SqlDataSourceA.SelectCommand = this.m_strSQL;
this.gvTestForm.Visible = true;
this.gvTestForm.AllowPaging = true;
this.gvTestForm.PageSize = 10;
}
catch
{
basfuncs.MessageBox(this, "Wrong Query");
}
if (gvTestForm.Rows.Count > 0)
this.btnDetail.Enabled = true;
else
this.btnDetail.Enabled = false;
}
In my ASPNET 2.0 C# Web form, I have a funciton BindGridView for binding
SqlDataSourceA to the GridView gvTestForm.
And in the end of the function, I would like to check if there are no rows
in the GridView then the control btnDetail is disabled.
However, this function doesn't work as what I pland.
The gvTestForm.Rows.Count respond last time's Row, not the current row count
in ths SqlDataSourceA.
What have I done wrong?
Thanks for help.
Jason
public void BindGridView()
{
this.m_strStartDate = this.ddlStartYear.SelectedItem.Text +
this.ddlStartMonth.SelectedItem.Text + this.ddlStartDay.SelectedItem.Text;
this.m_strEndDate = this.ddlEndYear.Text + this.ddlEndMonth.Text +
this.ddlEndDay.Text;
try
{
this.SqlDataSourceA.SelectParameters["prAcceptDateStart"].DefaultValue
= this.m_strStartDate;
this.SqlDataSourceA.SelectParameters["prAcceptDateEnd"].DefaultValue
= this.m_strEndDate;
this.SqlDataSourceA.SelectCommand = this.m_strSQL;
this.gvTestForm.Visible = true;
this.gvTestForm.AllowPaging = true;
this.gvTestForm.PageSize = 10;
}
catch
{
basfuncs.MessageBox(this, "Wrong Query");
}
if (gvTestForm.Rows.Count > 0)
this.btnDetail.Enabled = true;
else
this.btnDetail.Enabled = false;
}