binding data to header

Discussion in 'ASP .Net Building Controls' started by vijaya, Nov 18, 2003.

  1. vijaya

    vijaya Guest

    Can we bind data to textbox in a headertemplate in a
    template column of a datagrid?

    I've tried with text box and table. But I couldn't
    succeeed.

    If aanyone has tried it,please help me out.Please give
    some code snippets.
    vijaya, Nov 18, 2003
    #1
    1. Advertising

  2. Hi Vijaya,

    The basic idea is to use the grid's ItemDataBound event. Here's an example.

    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
    CType(e.Item.Cells(1).FindControl("Button1"),
    WebControls.TextBox).Text = "hello"
    End If
    End Sub

    However, my example uses static text, "hello". You can write an entire
    database selection function here in this event. Another option is to walk
    through your dataset before closing it and storing the desired value in a
    global variable for later use here. In any case, ItemDataBound is the place
    to do it.

    Thank you, Mike
    Microsoft, ASP.NET Support Professional

    Microsoft highly recommends to all of our customers that they visit the
    http://www.microsoft.com/protect site and perform the three straightforward
    steps listed to improve your computer’s security.

    This posting is provided "AS IS", with no warranties, and confers no rights.


    --------------------
    > Content-Class: urn:content-classes:message
    > From: "vijaya" <>
    > Sender: "vijaya" <>
    > Subject: binding data to header
    > Date: Tue, 18 Nov 2003 03:54:34 -0800
    > Lines: 9
    > Message-ID: <081701c3adca$bbbdc100$>
    > MIME-Version: 1.0
    > Content-Type: text/plain;
    > charset="iso-8859-1"
    > Content-Transfer-Encoding: 7bit
    > X-Newsreader: Microsoft CDO for Windows 2000
    > Thread-Index: AcOtyru96kpxNUxZRSuracij1nHAGQ==
    > X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
    > Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    > Path: cpmsftngxa06.phx.gbl
    > Xref: cpmsftngxa06.phx.gbl

    microsoft.public.dotnet.framework.aspnet.buildingcontrols:8163
    > NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
    > X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    >
    > Can we bind data to textbox in a headertemplate in a
    > template column of a datagrid?
    >
    > I've tried with text box and table. But I couldn't
    > succeeed.
    >
    > If aanyone has tried it,please help me out.Please give
    > some code snippets.
    >
    >
    Mike Moore [MSFT], Nov 18, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jordan
    Replies:
    2
    Views:
    2,518
    Jordan
    Feb 10, 2004
  2. Amit
    Replies:
    6
    Views:
    13,756
    Assimalyst
    Oct 24, 2006
  3. Santosh
    Replies:
    0
    Views:
    1,846
    Santosh
    Aug 4, 2006
  4. mlt
    Replies:
    2
    Views:
    814
    Jean-Marc Bourguet
    Jan 31, 2009
  5. JcFx
    Replies:
    0
    Views:
    266
Loading...

Share This Page