Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
180
Header Text as Caption from DataTable
posted

I am using WHDG 12.1, and I am using a HierarchicalDataSource which is binded to a objectdatasource (DataSet). The data all loads fine, but I want to change the headers of the columns.

They are currently use the column name, but I want it to use the caption from the datacolumn within the dataset.

I know this would be easy to do in markup but I have no idea what information the user would be requesting, so is there anyway to find a column in codebehind and change the header.Text?

Another Problem: How would I hide a column in code based if DataColumn.ExtendedProperties.Count > 0? Again I don't know what column it would be, so I need it done in code

Any help would be great! Thanks

 

The aspx page mark up:

<ig:WebHierarchicalDataGrid ID="dataGrid2" runat="server"
        Height="600px" Width="100%" DataSourceID="WebHierarchicalDataSource1"
          ondatabound="dataGrid2_DataBound">
          <GroupingSettings EnableColumnGrouping="True" />
          <Behaviors>
            <ig:Sorting Enabled="true" />
            <ig:ColumnMoving Enabled="true" />
            <ig:ColumnResizing Enabled="true" />
            <ig:VirtualScrolling Enabled="true" ScrollingMode="Virtual" />
          </Behaviors>
        </ig:WebHierarchicalDataGrid>
    <ig:WebHierarchicalDataSource ID="WebHierarchicalDataSource1" runat="server">
        <dataviews>
            <ig:DataView ID="Data" DataMember="DefaultView"
                DataSourceID="ObjectDataSource1" />
        </dataviews>
    </ig:WebHierarchicalDataSource>
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
        OldValuesParameterFormatString="original_{0}"
        onobjectcreating="ObjectDataSource1_ObjectCreating"
        onselecting="ObjectDataSource1_Selecting" SelectMethod="getFilterData"
        TypeName="Convallis.CRM.Business.Filters.FilterHandler"
          onselected="ObjectDataSource1_Selected">
        <SelectParameters>
            <asp:ControlParameter Name="filterID" ControlID="queryList" PropertyName="SelectedValue" Type="Int32" />
            <asp:Parameter Name="clientID" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>

Parents
  • 33839
    Suggested Answer
    posted

    Hi fliteska,

    You could submit a feature request for the grid displaying the CaptionName as the HeaderText.  You are autogenerating columns, so the Columns collections of the Bands and ContainerGrids will all be empty.  The columns that are displayed are in an internal Fields collection.  You cannot access this.  The only way to get to a field is off of a cell's Column property (this is after data binding, maybe in initialize row).  Then you could set cell.Column.Header.Text or cell.Column.Hidden.

    regards,
    David Young 

Reply Children