Bind dataset table to webpart for showing dataset content on kentico portal page

Narendra Dol asked on January 18, 2017 14:34

i had implement tax class for custom tax connector and overrided method GetTaxesInternal() return dataset which contain records but i want to bind tax value column of that dataset to webpart of kentico and need to show tax value as separate field on kentico portal page but i am not able to do this so please provide proper solution

Recent Answers


Trevor Fayas answered on January 18, 2017 15:24

Hopefully i'm following you correctly:

You want to display a DataSet of the tax data on a page, correct?

The easiest way to display any such data is to use the Repeater with Custom Query, which allows you to create a query (such as "Select taxValue as MyValue from MyCustomTaxTable") and repeat it out (you can then use the repeater to build a table structure).

There are also other tools that can do more if you need additional functionality, but you may need to make a custom webpart to utilize them (see documentation on the UniGrid).

If you can't do this in a query and only have a DataSet object, take a look at the code section below, this is how you load your own custom dataset into a repeater:

<cms:BasicRepeater runat="server" ID="basicRepeater" />

And for the code behind

// In the code behind
protected void SetupControl()
{
    if (StopProcessing)
    {
        // do nothing
    }
    else
    {
        basicRepeater.ItemTemplate = CMSDataProperties.LoadTransformation(this, TransformationName);
        basicRepeater.ReloadData(true);
    }
}

/// <summary>
/// Binds datasource control data to the viewer control
/// </summary>
private void BindControl()
{

    basicRepeater.DataSource = GetContentDataSet();
    basicRepeater.ItemTemplate = CMSDataProperties.LoadTransformation(this, TransformationName);
    basicRepeater.DataBind();
    binded = true;
}

protected override void OnPreRender(EventArgs e)
{
    // Notice to user so they can fix.
    if (StopProcessing)
    {

    }
    else
    {
        // Datasource data
        object ds = null;

        // Set transformations if data source is not empty
        // Get data from datasource
        ds = GetContentDataSet();

        // Check whether data exist
        if ((!DataHelper.DataSourceIsEmpty(ds)) && (!binded))
        {
            basicRepeater.DataSource = ds;
            basicRepeater.ItemTemplate = CMSDataProperties.LoadTransformation(this, TransformationName);
            basicRepeater.DataBind();
        }

        base.OnPreRender(e);

        // Hide control for zero rows
        if (DataHelper.DataSourceIsEmpty(ds))
        {
            Visible = false;
        }
    }
}

/// <summary>
/// Reload data.
/// </summary>
public override void ReloadData()
{
    SetupControl();
    base.ReloadData();
}

That should aid you in doing what you need to do, just replace the "GetContentDataSet" method to return your dataset

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.