hiii
i have some problem.
How to count total value from dropdownlist and show in gridview footer.
when value change in dropdownlist the total count will show in footer.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Deepak VermaPosted Oct 16, 2013, 7:02 AM
ranjan sahooPosted Oct 16, 2013, 6:42 AM
your concept is right . but the result is not showing
Deepak VermaPosted Oct 16, 2013, 6:16 AM
here is a simple demo which solves your problem. This demo uses jquery approach.
Code Behind:
using System;
using System.Collections.Generic;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
List<Number> list = new List<Number>();
list.Add(new Number("1"));
list.Add(new Number("2"));
list.Add(new Number("3"));
list.Add(new Number("4"));
GridView1.DataSource = list;
GridView1.DataBind();
}
public class Number
{
public string Num { get; set; }
public Number(string str)
{
this.Num = str;
}
}
}
ASPX
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:TemplateField HeaderText="Serial Number">
<ItemTemplate>
<%# ((Number)Container.DataItem).Num %>
ItemTemplate>
asp:TemplateField>
<asp:TemplateField HeaderText="Values">
<ItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" ClientIDMode="Static" CssClass="items">
<asp:ListItem>1asp:ListItem>
<asp:ListItem>2asp:ListItem>
<asp:ListItem>3asp:ListItem>
<asp:ListItem>4asp:ListItem>
asp:DropDownList>
ItemTemplate>
asp:TemplateField>
Columns>
asp:GridView>
<br />
Total : <asp:Label ID="LabelTotal" runat="server" ClientIDMode="Static">asp:Label>
<script>
$(document).ready(function () {
CalculateTotal();
$('.items').change(function () { CalculateTotal(); });
});
function CalculateTotal() {
var val = 0;
$('.items').each(function () {
val = val + parseFloat($(this).find('option:selected').val());
});
$('#LabelTotal').text(val);
val = 0;
}
script>
Cheers!
ranjan sahooPosted Sep 28, 2013, 3:10 AM
ranjan sahooPosted Sep 27, 2013, 1:24 PM
Sanjeeb LenkaPosted Sep 27, 2013, 7:04 AM
ranjan sahooPosted Sep 27, 2013, 6:41 AM
ranjan sahooPosted Sep 27, 2013, 6:39 AM
ranjan sahooPosted Sep 27, 2013, 6:39 AM
Sanjay KumarPosted Sep 27, 2013, 6:37 AM
http://www.aspmemo.net/2012/04/how-to-edit-gridview-row-data-in-client.html
ranjan sahooPosted Sep 27, 2013, 6:35 AM
ranjan sahooPosted Sep 27, 2013, 6:33 AM
Sanjay KumarPosted Sep 27, 2013, 6:28 AM
http://www.webcodeexpert.com/2013/08/how-to-get-dropdownlist-selected-value.html#.UkVefNIyaaY
ranjan sahooPosted Sep 27, 2013, 6:26 AM
Sanjeeb LenkaPosted Sep 27, 2013, 6:15 AM
http://stackoverflow.com/questions/11734308/displaying-total-in-footer-of-gridview-and-also-add-sum-of-columnsrow-vise-in
ranjan sahooPosted Sep 27, 2013, 5:52 AM
ranjan sahooPosted Sep 27, 2013, 5:37 AM
ranjan sahooPosted Sep 27, 2013, 5:23 AM
ranjan sahooPosted Sep 27, 2013, 5:23 AM
ranjan sahooPosted Sep 27, 2013, 5:16 AM
ranjan sahooPosted Sep 27, 2013, 5:11 AM
Sanjay KumarPosted Sep 27, 2013, 5:03 AM
try link
http://www.aspmemo.net/2012/04/how-to-edit-gridview-row-data-in-client.html
http://weblogs.asp.net/ashrafurrahaman/archive/2009/02/26/javascript-for-gridview-row-level.aspx
Sanjay KumarPosted Sep 27, 2013, 4:56 AM
http://msdn.microsoft.com/en-us/library/bb310552.aspx
http://www.asp.net/web-forms/tutorials/data-access/custom-formatting/displaying-summary-information-in-the-gridview-s-footer-cs
Sanjeeb LenkaPosted Sep 27, 2013, 4:54 AM
can you provide more clear details of your requirement.
ranjan sahooPosted Sep 27, 2013, 4:52 AM
ranjan sahooPosted Sep 27, 2013, 4:06 AM