473,387 Members | 1,790 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,387 software developers and data experts.

Missing header text and values for templatecolumn

Hi,

I use a datagrid with asp:templatecolumn, and handles the datagrid's
ItemDataBound event, whereby I assign a value to this asp:templatecolumn text.

e.Item.Cells[1].Text = e.Item.Cells[2].Text + e.Item.Cells[3].Text;
/* column index 2 and 3 are boundcolumn */

The issue that I have is that the column header (index 1) would be blank
after it.

Furthermore, after postback, the values for the individual rows (only column
index 1) will be missing as well. Is this because on postback, as I didn't
rebind the datagrid, so the event didn't run, thus the system erase the data
from that particular column?

Anyhow that I can fix these two issues?

Thanks.
Jul 28 '07 #1
2 3266
On Jul 28, 4:52 pm, Eugene <Eug...@discussions.microsoft.comwrote:
Hi,

I use a datagrid with asp:templatecolumn, and handles the datagrid's
ItemDataBound event, whereby I assign a value to this asp:templatecolumn text.

e.Item.Cells[1].Text = e.Item.Cells[2].Text + e.Item.Cells[3].Text;
/* column index 2 and 3 are boundcolumn */

The issue that I have is that the column header (index 1) would be blank
after it.

Furthermore, after postback, the values for the individual rows (only column
index 1) will be missing as well. Is this because on postback, as I didn't
rebind the datagrid, so the event didn't run, thus the system erase the data
from that particular column?

Anyhow that I can fix these two issues?

Thanks.
Hi.. a little bit strange problem ... because what ever you do if you
don't change the header text it is suppose to persists after post
back...
did you changed you databoundcode after chacking the rowtype...
protected void gdvData_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// your code goes here...
}
}

one more thing ... check your gridviews EnableViewState property set
to true or not....
can could you please show some sample code of your templatecolumn....

Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com

Jul 28 '07 #2
Hi Masudur,

thanks. but i can't find e.Row.RowType as i use ItemDataBound instead of
RowDataBound. Should I enable the viewstate for it to work?
eg.
<asp:templatecolumn headertext="Name">
<itemstyle horizontalalign="left" width="15%"></itemstyle>
<itemtemplate>
<asp:label id="lblDisplayedName" runat="server" />
</itemtemplate> </asp:templatecolumn>
"Masudur" wrote:
On Jul 28, 4:52 pm, Eugene <Eug...@discussions.microsoft.comwrote:
Hi,

I use a datagrid with asp:templatecolumn, and handles the datagrid's
ItemDataBound event, whereby I assign a value to this asp:templatecolumn text.

e.Item.Cells[1].Text = e.Item.Cells[2].Text + e.Item.Cells[3].Text;
/* column index 2 and 3 are boundcolumn */

The issue that I have is that the column header (index 1) would be blank
after it.

Furthermore, after postback, the values for the individual rows (only column
index 1) will be missing as well. Is this because on postback, as I didn't
rebind the datagrid, so the event didn't run, thus the system erase the data
from that particular column?

Anyhow that I can fix these two issues?

Thanks.

Hi.. a little bit strange problem ... because what ever you do if you
don't change the header text it is suppose to persists after post
back...
did you changed you databoundcode after chacking the rowtype...
protected void gdvData_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// your code goes here...
}
}

one more thing ... check your gridviews EnableViewState property set
to true or not....
can could you please show some sample code of your templatecolumn....

Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com

Jul 29 '07 #3

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

Similar topics

1
by: Webgour | last post by:
Hi, I'm tring to add a column to a datagrid with a linkbutton as header that can be used to sort the column. The column and the linkbutton are added programmatically (see below). However the...
5
by: Stan | last post by:
I would like my header column span multiple columns, for example: Date Ready Open Close --------------------------- 08/06 10 am 5pm How can I do that? Thanks,
0
by: Jim Heavey | last post by:
Hello, I am trying to figure out how to use the <HeaderTemplate>. I had a datagrid working fully. Then I wanted to put a checkbox in one of the header columns. When I added the <HeaderTemplate>...
1
by: vijaya | last post by:
i want to bind data to the header template of template column using any one of the web server controls like button,textbox etc. The data comes from the database through the sql select...
5
by: bg | last post by:
Hi! How do I check if "date" exists before using that code? I've built a RSSreader and sometimes there's a date in it and sometimes not. How can I check if it exists to avoid crash...
6
by: tshad | last post by:
I have a datagrid where each column has both a label and a linkbutton. I need to have the label left justified and the linkbutton right justified. In HTML, I would have to set up 2 cells to do...
1
by: Dave | last post by:
Hi, I'm trying to use templated columns to format the header for my datagrid. Can I use the HeaderTemplate to make the "My Title Goes.." text to span across the entire datagrid table when it's...
2
by: Santosh | last post by:
Dear all i want to bind data to datagrid header template i am wrtting follwing code it is displaying data with in item template not but it is display data in header template <asp:DataGrid...
7
by: bkasmai | last post by:
This is driving me crazy. I need to hide rows that a particular cell is zero. On debuggng I fiound out that ItemDataBound fires for header only and not for Item and AlternatingItem private void...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
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,...

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.