I want a hyperlink on the column header of a WebDataGrid. Does anybody know how this can be done?
ThanksNick
Hello Nick,Thank you for posting in our community. This is actually quite easy to achieve. You have to just use header template. This is a code demonstrating how to achieve the desired look of the grid:
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px" AutoGenerateColumns="False"> <Columns> <ig:BoundDataField Key="id" DataFieldName="id" Header-Text="id"><Header Text="id" TemplateId="Template1"></Header> </ig:BoundDataField> </Columns> <Templates> <ig:ItemTemplate ID="WebDataGrid1Template1" runat="server" TemplateID="Template1"> <Template> <a href="http://es.infragistics.com/">Visit Infragistics</a> </Template> </ig:ItemTemplate> </Templates> </ig:WebDataGrid>
Hi Nikifor,
Thanks very much for your answer. The grid is actually dynamically created using code on the server. i.e;
Dim DataGrid As New Infragistics.Web.UI.GridControls.WebDataGridParent.Controls.Add(DataGrid)
DataGrid.AutoGenerateColumns = False DataGrid.DataSource = DataTable DataGrid.Columns.Clear()
Dim DataColumn As System.Data.DataColumn For Each DataColumn In DataTable.ColumnsDim BoundField As New Infragistics.Web.UI.GridControls.BoundDataField(True)
BoundField.DataFieldName = DataColumn.ColumnName BoundField.Key = DataColumn.ColumnName DataGrid.Columns.Add(BoundField) BoundField.Header.Text = GetColumnLabel(DataColumn.ColumnName)
Next
I'm struggling to convert the markup to code building this structure using the object model. Any help much appreciated.