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
165
whdg datarelation manual markup
posted

Hi,

I am using NetAdvantage 12.2 and have implemented a solution using the webhierarchicaldatagrid. I have given up trying to use the webhierarchicaldatasource with stored procedures...it's just too broken (I guess?) and have gone to a code behind solution using datarelations to populate the bands. Now I want to turn off the autocolumn and autoband features and write the band and column control manually using markup. I have the top level markup working to control the columns.

But I can't get the Band markup to recognize my markup. I would like to see an example of:

codebehind using datarelations and manual markup of the whdg uilitzing multiple bands with column control.

Any help will be appreciated, TIA, Jim Spicer

  • 165
    posted

    Hi again,

    Well noone replied so below is the direction I am now trying...maybe it will help someone else.

    Public Sub LoadWHDG(ByVal strVendorsID As String, ByVal strUsersDataID As String)

    WebHierarchicalDataGrid1.DataSourceID = Nothing 'clear the control

    WebHierarchicalDataGrid1.DataBind()

    Dim ds As New System.Data.DataSet
    Dim dt As New System.Data.DataTable

    ds.Tables.Add(GetPOReport(0, "Jobs" & Session("CoName"), "VendorProjects" & Session("CoName"), "dbo.usp_getVendorPOListByVendor", strVendorsID, strUsersDataID, True))
    dt = clsCustParams.GetLineItemsFromVendorsID(strVendorsID, Session("CoID"), Session("ProjID"), "Transactions" & Session("CoName"), "Jobs" & Session("CoName"), "Types" & Session("CoName"), True)
    ds.Tables.Add(dt)

    Dim relJobs As New DataRelation("Jobs", ds.Tables(0).Columns("Job_ID"), ds.Tables(1).Columns("Job_ID"), True)

    ds.Relations.Add(relJobs)

    ' Create band
    Dim childBand As New Band()
    childBand.DataKeyFields = "Job_ID"

    ' Set the key from the data source
    childBand.Key = "Job_ID"
    ' Set the data member from the data source to bind to
    childBand.DataMember = dt.TableName

    Me.WebHierarchicalDataGrid1.AutoGenerateBands = False
    Me.WebHierarchicalDataGrid1.Bands.Add(childBand)
    Me.WebHierarchicalDataGrid1.Bands("Job_ID").AutoGenerateColumns = False

    Dim boundField As New BoundDataField(True)
    ' Define column for the child band
    boundField = New BoundDataField(True)
    boundField.Key = "Date"
    boundField.Header.Text = "Date"
    'Bind to Product ID field in data source
    boundField.DataFieldName = "Date"
    childBand.Columns.Add(boundField)
    childBand.Columns("Date").Width = 80
    '--------------------------------------------DATE
    boundField = New BoundDataField(True)
    boundField.Key = "Estimate"
    boundField.Header.Text = "Amount"
    boundField.DataFieldName = "Estimate"
    childBand.Columns.Add(boundField)
    childBand.Columns("Estimate").Width = 100
    '--------------------------------------------AMOUNT
    boundField = New BoundDataField(True)
    boundField.Key = "Description"
    boundField.Header.Text = "Description"
    boundField.DataFieldName = "Description"
    childBand.Columns.Add(boundField)
    childBand.Columns("Description").Width = 200
    '--------------------------------------------DESCRIPTION
    WebHierarchicalDataGrid1.DataKeyFields = "Job_ID"

    WebHierarchicalDataGrid1.DataSource = ds

    WebHierarchicalDataGrid1.DataBind()

    End Sub

    Jim