Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

Missing header text and values for templatecolumn

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eugene - 28 Jul 2007 11:52 GMT
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.
Masudur - 28 Jul 2007 12:10 GMT
> Hi,
>
[quoted text clipped - 15 lines]
>
> 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
Eugene - 29 Jul 2007 11:16 GMT
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>

> > Hi,
> >
[quoted text clipped - 38 lines]
> www.kaz.com.bd
> http://munnacs.110mb.com
Masudur - 29 Jul 2007 13:16 GMT
Hi,

Sorry missed out the point that you are using datagrid...
is it asp.net 1.1 or 2.0?
try this...
protected void DataGrid1_ItemDataBound(object sender,
DataGridItemEventArgs e)
       {
           if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
           {
               //your code goes here
           }
       }
and viewstate of datagrid should be enabled...

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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.