binding data to header

V

vijaya

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.
 
M

Mike Moore [MSFT]

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.


--------------------
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top