Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 27th, 2005, 05:05 AM
Authorized User
 
Join Date: Mar 2005
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datagrid template column problem

helo all,

            this seems to be funny.but this is what i really want 2 do.i have a datagrid.i am inserting a template column at design time and i am putting some labels in header template.

at run time before databinding to that datagrid, i want 2 change the caption of the labels in page load. is there any shortcut way to do this?

that is before assigning some tables to the datagrid i want 2 change the caption of the labels in page load.

regards
Sonnu


 
Old September 27th, 2005, 12:53 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Use the ItemDataBound event of the grid:

    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
        If e.Item.ItemType = ListItemType.Header Then
            Dim lbl As Label
            lbl = e.Item.Cells(<index of cell you want to change).FindControl("lblTest")
            lbl.Text = "Some Text"
        End If
    End Sub

Repeate for each column you want to change






Similar Threads
Thread Thread Starter Forum Replies Last Post
Template Column in datagrid prankur ASP.NET 1.0 and 1.1 Professional 1 January 7th, 2006 05:20 PM
template column in datagrid p2pMember ASP.NET 1.0 and 1.1 Basics 1 November 18th, 2005 06:33 PM
Datagrid template column sonurijs ASP.NET 1.x and 2.0 Application Design 1 September 27th, 2005 12:55 PM
Datagrid template column problem lore6673 ASP.NET 1.x and 2.0 Application Design 1 December 3rd, 2003 11:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.