To make Progress Bar in GridView.
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>
Namespaces code: - 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();
- }
- }