protected void Page_Load(object
sender, EventArgs e)
{
if
(!IsPostBack)
GetAllReportAbuse();
}
private
void GetAllReportAbuse()
{
try
{
grdReportAbuse.DataSource = Forum.GetAllAbuseReportData();
grdReportAbuse.DataBind();
if
(grdReportAbuse.Rows.Count == 0)
EmptyGridFix(grdReportAbuse); // call the Function
}
catch
(Exception ex)
{
AppBase.handleException("Form:ReportAbues, Function:GetAllReportAbuse()",
ex);
}
}
protected void EmptyGridFix(GridView
grdView)
{
try
{
if
(grdView.Rows.Count == 0 &&
grdView.DataSource != null)
{
DataTable
dt = null;
if
(grdView.DataSource is DataSet)
{
dt = ((DataSet)grdView.DataSource).Tables[0].Clone();
}
else
if (grdView.DataSource is
DataTable)
dt = ((DataTable)grdView.DataSource).Clone();
if
(dt == null)
return;
dt.Rows.Add(dt.NewRow()); // add empty row
grdView.DataSource = dt;
grdView.DataBind();
//
hide row
grdView.Rows[0].Visible = false;
grdView.Rows[0].Controls.Clear();
}
// normally
executes at all postbacks
if
(grdView.Rows.Count == 1 &&
grdView.DataSource == null)
{
bool
bIsGridEmpty = true;
//
check first row that all cells empty
for
(int i = 0; i < grdView.Rows[0].Cells.Count;
i++)
{
if (grdView.Rows[0].Cells[i].Text != string.Empty)
{
bIsGridEmpty = false;
}
}
//
hide row
if
(bIsGridEmpty)
{
grdView.Rows[0].Visible
= false;
grdView.Rows[0].Controls.Clear();
}
}
}
catch
(Exception ex)
{
AppBase.handleException("Form:ReportAbues, Function:EmptyGridFix",
ex);
}
}
No comments :
Post a Comment