I have a page that has drop down list and a user control
The user control generate graphs and data grids for web enabled reports.
Inside my UC i have
I have 17 different reports. However, here is what is happening. As I change the drop down list for each chart type, the graph is generated and the grid is created. I am adding the grids to the pnlData but when I try to loop through the cells and format them, it only seems to work the first time.
Any ideas or suggestions? I have tried a bunch of different things, and not sure what I am doing wrong here. I am guessing this is because of the update panel or I have something setup wrong with the update panel.
The user control generate graphs and data grids for web enabled reports.
Code:
protected void Page_Load(object sender, EventArgs e)
{
uc_report.sChartType = ddlChartType.SelectedValue;
}
Inside my UC i have
Code:
<asp:UpdatePanel ID="FusionChartsUP" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlChart" runat="server" Width="950px" Height="100%" ></asp:Panel>
<asp:Panel ID="pnlData" runat="server" Width="950px" Height="100%" > </asp:Panel>
<asp:GridView ID="gvData" runat="server" ForeColor="#333333">
<AlternatingRowStyle BackColor="White" ForeColor="#333333" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
I have 17 different reports. However, here is what is happening. As I change the drop down list for each chart type, the graph is generated and the grid is created. I am adding the grids to the pnlData but when I try to loop through the cells and format them, it only seems to work the first time.
Any ideas or suggestions? I have tried a bunch of different things, and not sure what I am doing wrong here. I am guessing this is because of the update panel or I have something setup wrong with the update panel.
Code:
switch (iEncounterType.ToString())
{
case "1":
//Admissions By Financial Class
gvData_Counts_Admits.ShowHeader = true;
gvData_Counts_Admits.ID = "gvData_Counts_Admits";
gvData_Counts_Admits.Width = Unit.Pixel(950);
gvData_Counts_Admits.AlternatingRowStyle.BackColor = Color.White;
gvData_Counts_Admits.AlternatingRowStyle.ForeColor = Color.Black;
gvData_Counts_Admits.RowStyle.BackColor = Color.FromArgb(247, 246, 243);
gvData_Counts_Admits.RowStyle.ForeColor = Color.Black;
gvData_Counts_Admits.DataSource = null;
gvData_Counts_Admits.DataBind();
gvData_Counts_Admits.DataSource = dtDisplay;
gvData_Counts_Admits.DataBind();
gvData_Counts_Admits_Pct.ShowHeader = true;
gvData_Counts_Admits_Pct.ID = "gvData_Counts_Admits_Pct";
gvData_Counts_Admits_Pct.Width = Unit.Pixel(950);
gvData_Counts_Admits_Pct.AlternatingRowStyle.BackColor = Color.White;
gvData_Counts_Admits_Pct.AlternatingRowStyle.ForeColor = Color.Black;
gvData_Counts_Admits_Pct.RowStyle.BackColor = Color.FromArgb(247, 246, 243);
gvData_Counts_Admits_Pct.RowStyle.ForeColor = Color.Black;
gvData_Counts_Admits_Pct.DataSource = null;
gvData_Counts_Admits_Pct.DataBind();
gvData_Counts_Admits_Pct.DataSource = dtDisplay_Pct;
gvData_Counts_Admits_Pct.DataBind();
pnlData.Controls.Add(gvData_Counts_Admits);
pnlData.Controls.Add(new LiteralControl("<br/><br/>"));
pnlData.Controls.Add(gvData_Counts_Admits_Pct);
//========================================================================
rowscount = gvData_Counts_Admits.Rows.Count;
for (int x = 0; x < rowscount; x++)
{
for (int i = 0; i < gvData_Counts_Admits.Rows[0].Cells.Count; i++)
{
if (i > 0)
{
gvData_Counts_Admits.Rows[x].Cells[i].Width = Unit.Pixel(125);
int iResult;
if (gvData_Counts_Admits.Rows[x].Cells[i].Text != " ")
{
//iResult = Convert.ToInt32(gvData_Counts_Admits.Rows[x].Cells[i].Text);
//gvData_Counts_Admits.Rows[x].Cells[i].Text = String.Format("{0:#,###0}", iResult);
}
}
gvData_Counts_Admits.Rows[x].Cells[i].HorizontalAlign = HorizontalAlign.Center;
}
}
//========================================================================
//========================================================================
rowscount_pct = gvData_Counts_Admits_Pct.Rows.Count;
for (int x = 0; x < rowscount_pct; x++)
{
for (int i = 0; i < gvData_Counts_Admits_Pct.Rows[0].Cells.Count; i++)
{
if (i > 0)
{
gvData_Counts_Admits_Pct.Rows[x].Cells[i].Width = Unit.Pixel(125);
decimal dResult;
if (gvData_Counts_Admits_Pct.Rows[x].Cells[i].Text != " ")
{
//dResult = Convert.ToDecimal(gvData_Counts_Admits_Pct.Rows[x].Cells[i].Text);
//gvData_Counts_Admits_Pct.Rows[x].Cells[i].Text = String.Format("{0:p0}", dResult);
}
}
gvData_Counts_Admits_Pct.Rows[x].Cells[i].HorizontalAlign = HorizontalAlign.Center;
}
}
//========================================================================
break;
case "2":
//Observations By Financial Class
gvData_Counts_Observations.ShowHeader = true;
gvData_Counts_Observations.ID = "gvData_Counts_Observations";
gvData_Counts_Observations.Width = Unit.Pixel(950);
gvData_Counts_Observations.AlternatingRowStyle.BackColor = Color.White;
gvData_Counts_Observations.AlternatingRowStyle.ForeColor = Color.Black;
gvData_Counts_Observations.RowStyle.BackColor = Color.FromArgb(247, 246, 243);
gvData_Counts_Observations.RowStyle.ForeColor = Color.Black;
gvData_Counts_Observations.DataSource = null;
gvData_Counts_Observations.DataBind();
gvData_Counts_Observations.DataSource = dtDisplay;
gvData_Counts_Observations.DataBind();
gvData_Counts_Observations_Pct.ShowHeader = true;
gvData_Counts_Observations_Pct.ID = "gvData_Counts_Observations_Pct";
gvData_Counts_Observations_Pct.Width = Unit.Pixel(950);
gvData_Counts_Observations_Pct.AlternatingRowStyle.BackColor = Color.White;
gvData_Counts_Observations_Pct.AlternatingRowStyle.ForeColor = Color.Black;
gvData_Counts_Observations_Pct.RowStyle.BackColor = Color.FromArgb(247, 246, 243);
gvData_Counts_Observations_Pct.RowStyle.ForeColor = Color.Black;
gvData_Counts_Observations_Pct.DataSource = null;
gvData_Counts_Observations_Pct.DataBind();
gvData_Counts_Observations_Pct.DataSource = dtDisplay_Pct;
gvData_Counts_Observations_Pct.DataBind();
pnlData.Controls.Add(gvData_Counts_Observations);
pnlData.Controls.Add(new LiteralControl("<br/><br/>"));
pnlData.Controls.Add(gvData_Counts_Observations_Pct);
//========================================================================
rowscount = gvData_Counts_Observations.Rows.Count;
for (int x = 0; x < rowscount; x++)
{
for (int i = 0; i < gvData_Counts_Observations.Rows[0].Cells.Count; i++)
{
if (i > 0)
{
gvData_Counts_Observations.Rows[x].Cells[i].Width = Unit.Pixel(125);
int iResult;
if (gvData_Counts_Observations.Rows[x].Cells[i].Text != " ")
{
//iResult = Convert.ToInt32(gvData_Counts_Observations.Rows[x].Cells[i].Text);
//gvData_Counts_Observations.Rows[x].Cells[i].Text = String.Format("{0:#,###0}", iResult);
}
}
gvData_Counts_Observations.Rows[x].Cells[i].HorizontalAlign = HorizontalAlign.Center;
}
}
//========================================================================
//========================================================================
rowscount_pct = gvData_Counts_Observations_Pct.Rows.Count;
for (int x = 0; x < rowscount_pct; x++)
{
for (int i = 0; i < gvData_Counts_Observations_Pct.Rows[0].Cells.Count; i++)
{
if (i > 0)
{
gvData_Counts_Observations_Pct.Rows[x].Cells[i].Width = Unit.Pixel(125);
decimal dResult;
if (gvData_Counts_Observations_Pct.Rows[x].Cells[i].Text != " ")
{
//dResult = Convert.ToDecimal(gvData_Counts_Observations_Pct.Rows[x].Cells[i].Text);
//gvData_Counts_Observations_Pct.Rows[x].Cells[i].Text = String.Format("{0:p0}", dResult);
}
}
gvData_Counts_Observations_Pct.Rows[x].Cells[i].HorizontalAlign = HorizontalAlign.Center;
}
}
//========================================================================
break;