Thank you very much. That explains it.
I have a quick question, sort of related to what I am trying to do. I am
basically trying to calculate the total of a column. However, on every
event, the value is "". Please help.
public void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
DoTotal(e.Item.Cells[5].Text);
e.Item.Cells[5].Text = string.Format("{0:C}",
Convert.ToDouble(e.Item.Cells[5].Text));
}
else if(e.Item.ItemType == ListItemType.Footer)
{
e.Item.Cells[4].Text="Total";
e.Item.Cells[5].Text = string.Format("{0:C}", m_dTotal);
}
}
i9arcanes said:
Hi,
You are not doing anything wrong !!!
Your label control is inside the FooterTemplete of DataGride. Means
Datagrid is the container of the Label. Thats why you will not see any
corresponding object in code behind.
If you want to access this Label control in your code, you need to use
FindControl method.
Thanks & Regards,
i9arcanes
:
I forgot to add the my code:
<asp:TemplateColumn HeaderText="Amount"
SortExpression="Amount">
<ItemTemplate>
<%# String.Format("{0:C}",
DataBinder.Eval(Container.DataItem, "Amount")) %>
</ItemTemplate>
<FooterTemplate>
<asp:Label Runat="server" ID="lblTotal">99.95</asp:Label>
</FooterTemplate>
</asp:TemplateColumn>
:
I added a label server control in my aspx file. In the code behind, the IDE
does not generate the corresponding object like it does with buttons and
other objects.
What am I doing wrong? Is there a way to force the IDE to re-generate the
corresponding objects?
Appreciate your input.
J