|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Get Header TextI am trying to get the header text of the datagrid in the ItemDataBound event, but it returns an empty string. Here is what I did: Private Sub datagrid1_ItemDataBound(....) If e.Item.ItemType = ListItemType.Header Then Response.Write("Header Text" & e.Item.Cells(2).Text) End If end Sub And here is my desinger of the datagrid. <asp:datagrid id=....> .... <asp:TemplateColumn> ... </asp:TemplateColumn> <asp:TemplateColumn SortExpression="Day" HeaderText="Date"> ... </asp:TemplateColumn> .... </asp:datagrid> What I am doing wroing? I also tried the same code in the OnItemCreated event, but it returns also an empty string. Thanks Hi Vishal,
Try using the PreRender event? Private Sub DataGrid1_PreRender _ (ByVal sender As Object, _ ByVal e As System.EventArgs) _ Handles DataGrid1.PreRender Dim dgCell As TableCell dgCell = CType(DataGrid1.Controls(0). _ Controls(0). _ Controls(0), _ TableCell) Response.Write(dgCell.Text) End Sub Ken Microsoft MVP [ASP.NET] Toronto Show quoteHide quote "Vishal" <anonym***@discussions.microsoft.com> wrote in message news:020401c507ec$1f1b8260$a601280a@phx.gbl... > Hello, > > I am trying to get the header text of the datagrid in > the ItemDataBound event, but it returns an empty string. > > Here is what I did: > Private Sub datagrid1_ItemDataBound(....) > If e.Item.ItemType = ListItemType.Header Then > Response.Write("Header Text" & e.Item.Cells(2).Text) > End If > end Sub > > And here is my desinger of the datagrid. > > <asp:datagrid id=....> > ... > <asp:TemplateColumn> > ... > </asp:TemplateColumn> > <asp:TemplateColumn SortExpression="Day" HeaderText="Date"> > ... > </asp:TemplateColumn> > ... > </asp:datagrid> > > What I am doing wroing? I also tried the same code in the > OnItemCreated event, but it returns also an empty string. > > Thanks
multiple Rowfiltering and binding the changes to the datagrid
Using sqlDataAdapter to fill Dataset Casting a grid Refresh problem How to Make Calculator in ASP and Cold fusion Paging for DataList Control auto postback(urgent!) selecting a DataGridRow wipes out the selected row's text Suggestion Can You Change Colors on GridLines? |
|||||||||||||||||||||||