I want to create a LinearGauge collection based on a result set from a stored procedure. I will not know how many records will be returned until runtime, therefore, I cannot explicitly create instances of new linear gauges. I tried creating an ILIST of the type LinearGauge using the following statement but that was not allowed.
IList<LinearGauge> myGauges = new IList<LinearGauge>();
Can you suggest a way to create the gauge collection as I am looping through a result set? Thanks in advance for your help!
Success!!!!! Thank you so much for your help and patience with me.
it wouldn't be the same image, but all the images would look identical.
every time you call this code,
needleMarker.Value = Convert.ToSingle(objTransReader["CompStd_1"]);
you're updating the value of the only needle used by any of the gauges, so only the last value you set will be reflected on any gauge.
i recommend using separate markers, scales, etc in each gauge.
One thing that I am doing is creating only one instance of the markers, Numeric Axis, and scale. Each loop, I am only changing the marker values, then adding the marker to the same scale object, and the same scale object to the new gauge item in the collection. Could reusing the same marker, Axis and scale object for each gauge in the collection be causing the same image to be used for each gauge?
Thanks for the quick reply, but still no luck. Below is a portion of my code so you can see where I am assigning the value for the ID.
while (objTransReader.Read())
{
//tbldata.Rows.Add(new object[] { objTransReader["Zone"].ToString(), objTransReader["subZone"].ToString(), objTransReader["pctCompliance"], objTransReader["CompStd_1"] });
//gaugePosition = Convert.ToInt16((gaugeCounter / Convert.ToSingle(objTransReader["rows"])) * 100);
gaugePercent = Convert.ToInt16((1 / Convert.ToSingle(objTransReader["rows"])) * 100);
Response.Write("<tr><td>");
Response.Write(gaugeCounter);
Response.Write(" - ");
Response.Write(Convert.ToSingle(objTransReader["pctCompliance"]));
Response.Write(gaugePosition);
Response.Write(gaugePercent);
Response.Write("</td></tr>");
myGauges[gaugeCounter].BrushElement = mySimpleGradientBrushElement;
myScale.Markers.Add(needleMarker);
barMarker.Value = Convert.ToSingle(objTransReader["pctCompliance"]);
if (Convert.ToSingle(barMarker.Value) < .9)
barMarker.BrushElement = redBrushElement;
}
else
barMarker.BrushElement = greenBrushElement;
myScale.Markers.Add(barMarker);
myGauges[gaugeCounter].Scales.Add(myScale);
myGauges[gaugeCounter].Bounds = new System.Drawing.Rectangle(0, gaugePosition, 100, gaugePercent);
myGauges[gaugeCounter].BoundsMeasure = Measure.Percent;
ultraGauge1.ID = string.Concat("ultraGauge", gaugeCounter.ToString());
ultraGauge1.Gauges.Add(myGauges[gaugeCounter]);
gaugeCounter += 1;
gaugePosition += gaugePercent;
Response.Write("</table>");
// close all SQL objects.
sTransConn.Close();
sTransConn.Dispose();
sTransCmd.Dispose();
objTransReader.Close();
objTransReader.Dispose();
//ultraGauge1.ClientSideEvents.Click = "UltraGauge1_Click";
ultraGauge1.DeploymentScenario.Mode = ImageDeploymentMode.Session;
//ultraGauge1.DeploymentScenario.FilePath = "GaugeImages";
//ultraGauge1.ID = "ultraGuage1";
ultraGauge1.Height = Unit.Pixel(gaugeCounter * 50);
ultraGauge1.Width = Unit.Pixel(400);
ultraGauge1.TabIndex = 0;
this.Controls.Add(ultraGauge1);
//this.FindControl("form1").Controls.Add(ultraGauge1);
don't worry about the ImageUrl for now. just set the ID to something unique for every iteration of that loop.