473,480 Members | 1,841 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Label & Code Behind

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

--
Be Cool!
Jul 21 '05 #1
6 1757
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>
"thejackofall" wrote:
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

--
Be Cool!

Jul 21 '05 #2
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

"thejackofall" wrote:
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>
"thejackofall" wrote:
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

--
Be Cool!

Jul 21 '05 #3
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" wrote:
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

"thejackofall" wrote:
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>
"thejackofall" wrote:
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

--
Be Cool!

Jul 21 '05 #4
I assume that m_Total variable is a private member variable of ur class !!
Please check you DoTotal() function. May be in this function you are
reinitializing the variable "m_dTotal" or may be you are assigning a value of
local variable to m_dTotal in DoTotal() function. Otherwise your code should
work...
"thejackofall" wrote:
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" wrote:
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

"thejackofall" wrote:
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>
"thejackofall" wrote:

> 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
>
> --
> Be Cool!

Jul 21 '05 #5
No. My m_dTotal is initialized to 0.0f before the data is bound to the grid.
It's just that on every OnItemDataBound event, the expected data is not
there. The data for a date column is valid, but not the rest of the columns.

Thanks.
J

"i9arcanes" wrote:
I assume that m_Total variable is a private member variable of ur class !!
Please check you DoTotal() function. May be in this function you are
reinitializing the variable "m_dTotal" or may be you are assigning a value of
local variable to m_dTotal in DoTotal() function. Otherwise your code should
work...
"thejackofall" wrote:
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" wrote:
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

"thejackofall" wrote:

> 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>
>
>
> "thejackofall" wrote:
>
> > 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
> >
> > --
> > Be Cool!

Jul 21 '05 #6
No. My m_dTotal is initialized to 0.0f before the data is bound to the grid.
It's just that on every OnItemDataBound event, the expected data is not
there. The data for a date column is valid, but not the rest of the columns.

Thanks.
J

"i9arcanes" wrote:
I assume that m_Total variable is a private member variable of ur class !!
Please check you DoTotal() function. May be in this function you are
reinitializing the variable "m_dTotal" or may be you are assigning a value of
local variable to m_dTotal in DoTotal() function. Otherwise your code should
work...
"thejackofall" wrote:
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" wrote:
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

"thejackofall" wrote:

> 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>
>
>
> "thejackofall" wrote:
>
> > 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
> >
> > --
> > Be Cool!

Jul 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1434
by: Steven | last post by:
From a fairly good understanding of traditional ASP I am taking my first tentative steps into C#. Within Visual Studio, my first test is as follows: Default.aspx contains a placeholder...
2
3918
by: kaczmar2 | last post by:
I have an ASP.NET page written in VB.NET that has a label: <asp:Label runat="server" ID="lblStatus" CssClass="LabelTxt"></asp:Label> In my code behind, I am running some stored procedures and...
3
6612
by: PK9 | last post by:
I'm having some issues with using a Response.Write or the shortcut ( <%= ...) from within a label control. I cannot do this in the code behind, I need to do it here at runtime. I have a public...
6
289
by: thejackofall | last post by:
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...
1
4259
by: Jameel | last post by:
Hi Coders, How do i Add a Lable control to DataList to show the Count Files which belong the current Category. i have a DataList which displays categoryName,Description and File counter...
1
2737
by: Steve Hershoff | last post by:
I'm using VS 2003, and need to extract the text from an asp label in my code-behind file. The label is part of a DataList's ItemTemplate. I've noticed that in my ascx file (we're using User...
4
2944
by: Ben | last post by:
Hi, i have some problem to access from code-behind a label nested into a CreateWizard control. I use a html-table for align purpose only. I try to change the text property of the label with...
2
2328
by: Andy B | last post by:
I have the following listView control on a page: <asp:ListView ID="ListView1" runat="server" ItemPlaceholderID="PlaceHolder1"> <ItemTemplate> <dl> <dt>
9
7976
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have a MDI Container Form, with one label control on the Background of this container form. When I now open a child form, this form is behind the label ... and this looks ugly ... :-))...
0
7037
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7076
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6732
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4472
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2990
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.