I am using below code to show progress bar in % using value from Database.
In below code, I want to change 4 things:
1) I want to change the color of Progress Bar i.e., DarkGreen. How to do that?
2) I dont want to show numbers(%) inside Progress bar. (since there is another column showing the number in Gridview)
3) Is their anyway to use below Stylesheet inside a newly created stylesheet in my web project (just like creating own stylesheet)??
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/start/jquery-ui.css">
4) Please provide the link to download both the below javascript:
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
HTML code:
<div>
<asp:GridView ID="GridView1" HeaderStyle-BackColor="#3AC0F2" HeaderStyle-ForeColor="White"
runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-Width="150" />
<asp:BoundField DataField="Percentage" HeaderText="Percentage" ItemStyle-Width="150" />
<asp:TemplateField ItemStyle-Width="300">
<ItemTemplate>
<div class='progress'>
<div class="progress-label">
<%# Eval("Percentage") %></div>
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
<style type="text/css">
.ui-progressbar
{
position: relative;
}
.progress-label
{
position: absolute;
left: 50%;
top: 4px;
font-weight: bold;
text-shadow: 1px 1px 0 #fff;
}
body
{
font-family: Arial;
font-size: 10pt;
}
</style>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/start/jquery-ui.css">
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script type="text/javascript">
$(function () {
$(".progress").each(function () {
$(this).progressbar({
value: parseInt($(this).find('.progress-label').text())
});
});
});
</script>
C# code:
using System.Data;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("Name", typeof(string)),
new DataColumn("Percentage",typeof(string)) });
dt.Rows.Add(1, "John Hammond", 45);
dt.Rows.Add(2, "Mudassar Khan", 37);
dt.Rows.Add(3, "Suzanne Mathews", 67);
dt.Rows.Add(4, "Robert Schidner", 12);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
Please reply for my above 4 questions.