Articles in this section
Category / Section

How to get data for circular gauge from database using ASP.NET MVC?

1 min read

You can retrieve the value from the stored procedure and assign it to the pointer value of the ASP.NET MVC Circular Gauge. You can initialize all the properties from the code behind.

Step 1: Create a simple circular gauge with some ranges in code behind.

   Code behind:

            CircularScales scale1 = new CircularScales();

            List<Pointers> pointers = new List<Pointers>();

            Pointers pointer1 = new Pointers();

            pointer1.Value = 0;

            scale1.Pointers.Add(pointer1);

            scale1.ShowRanges = true;

            scale1.ShowScaleBar = true;

 

            this.CircularGauge.Scales.Add(scale1);

            this.CircularGauge.BackgroundColor = "transparent";

            this.CircularGauge.EnableAnimation = true;

 

      aspx page:

               <ej:CircularGauge ClientIDMode="Static" runat="server" ID="CircularGauge">       

        </ej:CircularGauge>

 

Step 2: Initialize the data fetched from the stored procedure.

           String strConnString =  ConfigurationManager

                 .ConnectionStrings["DefaultConnection1"].ConnectionString;

            SqlDataReader rt;

            SqlConnection con;

            SqlCommand cmd = new SqlCommand();

            con = new SqlConnection(strConnString);

 

            cmd.CommandType = CommandType.StoredProcedure;

            //stored procedure command execution

            cmd.CommandText = "GetPointerDetails";

            cmd.Connection = con;

            con.Open();

 

            // read the returned result form the procedure

            rt = cmd.ExecuteReader();

            if (rt.Read())

            {

                this.CircularGauge.Scales[0].Pointers[0].Value = Convert

                            .ToDouble(rt.GetValue(0));

            }       

            con.Close();

            con.Dispose();

 

The following screenshot illustrates the result of fetching data from the stored procedure and initializing all the properties from code behind.

Circular gauge with ranges and pointers

 

Sample Link: https://github.com/SyncfusionExamples/How-to-get-data-for-circular-gauge-from-database

 

Conclusion

I hope you enjoyed learning about how to get data for circular gauge from database using ASP.NET MVC.

You can refer to our  ASP.NET MVC Circular Gauge feature tour page to know about its other groundbreaking feature representations. You can also explore our  ASP.NET MVC Circular Gauge examples to understand how to present and manipulate data.

For current customers, you can check out our ASP.NET MVC Controls from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our ASP.NET MVC DataGrid and other ASP.NET MVC controls.

If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied