473,659 Members | 3,475 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Missing header text and values for templatecolumn

Hi,

I use a datagrid with asp:templatecol umn, and handles the datagrid's
ItemDataBound event, whereby I assign a value to this asp:templatecol umn 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 3278
On Jul 28, 4:52 pm, Eugene <Eug...@discuss ions.microsoft. comwrote:
Hi,

I use a datagrid with asp:templatecol umn, and handles the datagrid's
ItemDataBound event, whereby I assign a value to this asp:templatecol umn 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_RowData Bound(object sender,
GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.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:templateco lumn headertext="Nam e">
<itemstyle horizontalalign ="left" width="15%"></itemstyle>
<itemtemplate >
<asp:label id="lblDisplaye dName" runat="server" />
</itemtemplate> </asp:templatecol umn>
"Masudur" wrote:
On Jul 28, 4:52 pm, Eugene <Eug...@discuss ions.microsoft. comwrote:
Hi,

I use a datagrid with asp:templatecol umn, and handles the datagrid's
ItemDataBound event, whereby I assign a value to this asp:templatecol umn 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_RowData Bound(object sender,
GridViewRowEven tArgs e)
{
if (e.Row.RowType == DataControlRowT ype.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
8904
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 problem is that when you click the added column header it doesn't trigger the sort. The code : <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false"
5
1590
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
294
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> everything starts highlighting. I am following this example I found on a web site which show it as follows: <Columns> <asp:TemplateColumn> <HeaderTemplate> <b>My Header Text</b>
1
1243
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 statement, it shouldn't be a static text Is it possible to bind data from a source like dataset ot datatable to header template ? Plz help me out
5
724
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 (DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name date) <asp:DataGrid id="RssNewsGrid"
6
2185
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 this. Is there a way to accomplish this in a DataGrid (and have the text span both columns). What I have is:
1
1249
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 generated? Or some other method? Thanks. <asp:DataGrid ID="dgList" AutoGenerateColumns=False Runat=server> <Columns> <asp:TemplateColumn > <HeaderTemplate>My Title Goes Here.</HeaderTemplate> </asp:TemplateColumn>
2
8588
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 ID="datagrid" Runat="server" ShowHeader="True"> <Columns> <asp:TemplateColumn> <HeaderTemplate> <asp:Label ID="Label1" Runat="server" Text='<%#
7
1309
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 grdSelectionList_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem ) { if (e.Item.Cells.Text == "0")
0
8428
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8531
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1978
muto222
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.