Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Front end( what else i have to right in the front page according to dynamic upadte from stored procedure )

--------------------------------------------------------------------------------------------------------------------------------------------
ASP.NET
<asp:Chart ID="chtCampaignHits" runat="server" BackColor="76, 125, 126"
BorderDashStyle="Solid" BackSecondaryColor="White" BackGradientStyle="DiagonalLeft"
BorderWidth="2px" BorderColor="#1A3B69">
<BorderSkin SkinStyle="Emboss" />

<ChartAreas>
<asp:ChartArea Name="MainChartArea" BorderColor="64, 64, 64, 64" BorderDashStyle="Solid"
BackSecondaryColor="White" BackColor="64, 165, 191, 228" ShadowColor="Transparent"
BackGradientStyle="TopBottom">
</asp:ChartArea>
</ChartAreas>
</asp:Chart>

C#
.CS FILE (DYNAMIC UPDATE FROM STORED PROCEDURE)

-------------------------------------------------------------


if (dt.Rows.Count != 0)
{

//var v = (from row in dt.AsEnumerable()
// select row.Field<Int64>("Campaigntitle").ToString()).Distinct<string>(); priviouly this code

var v = (from Rows in dt.AsEnumerable()
select Rows.Field<string>("Campaigntitle").ToString()).Distinct<string>();

foreach (string s in v)
{
Console.WriteLine(s);

foreach (DataRow row in dt.Rows)
{
if (row.HasErrors)
{
Console.WriteLine(row.RowError);
}
}
// SHOULD I USE ROWFILTER OR ITS OPTIONAL.
dt.DefaultView.RowFilter = "count=" + s;  //TILL THIS THE CODE RUNNING FIND. WHEN COMES TO ADD SERIES IN GOING TO CATCH EXCEPTION. NEED  YOUR HELP !!
chtCampaignHits.Series[s].Enabled = true;
chtCampaignHits.Series.Add(new Series(s));
chtCampaignHits.Series[s].Label = s;

chtCampaignHits.Series[s].ChartArea = "MainChartArea";
chtCampaignHits.Series[s].ChartType = SeriesChartType.Line; //priviously chat was SeriesChartType.Spline;
chtCampaignHits.Series[s].BorderWidth = 3;
//this was above priviouly
chtCampaignHits.Series[s].Points.DataBindXY(dt.DefaultView, "Campaigntitle", dt.DefaultView, "hits");

}
chtCampaignHits.Legends.Add("Legend1");

chtCampaignHits.Legends["Legend1"].Enabled = true;
//chtCampaignHits.Legends["Legend1"].Alignment = System.Drawing.StringAlignment.Near;
chtCampaignHits.Legends["Legend1"].LegendStyle = LegendStyle.Row;
chtCampaignHits.Legends["Legend1"].Docking = Docking.Bottom;
chtCampaignHits.Legends["Legend1"].BackColor = System.Drawing.Color.FromName("#4C7D7E");
chtCampaignHits.Legends["Legend1"].BackGradientStyle = GradientStyle.DiagonalLeft;
}
}
catch (Exception)
{

Response.Write("Error in FillChartInfo");
}
Posted
Updated 5-Nov-15 20:43pm
v2

1 solution

You are trying to enable a series before adding it to chart
Move the line
C#
chtCampaignHits.Series[s].Enabled = true;

next to
C#
chtCampaignHits.Series.Add(new Series(s));


Your code should be
C#
chtCampaignHits.Series.Add(new Series(s));
chtCampaignHits.Series[s].Enabled = true;
chtCampaignHits.Series[s].Label = s;



Updated answer
C#
Your code should be 
chtCampaignHits.Series.Add(s);
chtCampaignHits.Series[s].Enabled = true;
chtCampaignHits.Series[s].Label = s;
 
Share this answer
 
v3
Comments
Member 11589472 6-Nov-15 2:54am    
my program not going to add series. its directly going to catch exeption.

chtCampaignHits.Series.Add(new Series(s));
Naz_Firdouse 6-Nov-15 3:56am    
what exception you are getting?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900