473,386 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1753
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
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
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
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
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
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
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
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
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
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
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.