Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
ASP .Net Datagrid Control
Update the FooterText of DataGrid programatically
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Gheorghe Popescu, post: 4258864"] Hello, I created a DataGrid control with two columns: - a template column that contains a checkbox with AutoPostBack set to true: <asp:TemplateColumn> <ItemTemplate> <asp:CheckBox Runat="server" ID="chkPay" AutoPostBack="True" /> </ItemTemplate> </asp:TemplateColumn> - a databound column that contains an monetary field. This column also has a footer where I want to show the total of all checked columns. I am doing the following: private void Page_Load(...) { if (!IsPostBack) { grid.DataSource = ...; grid.DataMember = ...; grid.DataBind(); } } private void Page_PreRender() { double _total = 0; // Recalculate the total foreach (DataGridItem dgi in grid.Items) { CheckBox cb = (CheckBox) dgi.Cells[0].Controls[1]; if (cb.Checked) { string amount = ((Label) dgi.Cells[2].Controls[1]).Text; _total += double.Parse(amount, NumberStyles.AllowCurrencySymbol | NumberStyles.AllowDecimalPoint); } } grid.Columns[1].FooterText = string.Format("{0:c}", _total); } This code doesn't set the footer text in the grid (it shows up as blank). Do you know what I am doing wrong? Thank you, Gheorghe Popescu [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
ASP .Net Datagrid Control
Update the FooterText of DataGrid programatically
Top