UniSelector UniGrid OnExternalDataBound

Delford Chaffin asked on January 6, 2016 15:33

I have the following UniSelector on a page:

<cms:UniSelector ID="usProducts" runat="server" ObjectType="ecommerce.sku" SelectionMode="Multiple" />

... defined by this XML:

<?xml version="1.0" encoding="utf-8" ?>
<grid> 
  <columns>
    <column source="##ALL##" externalsourcename="Select" wrap="false" text-align="center" />
    <column source="SKUNumber" caption="SKU Number" wrap="false" localize="false" />
    <column source="SKUID" caption="SKU Name" wrap="false" externalsourcename="Product" />
  </columns>
  <options>
    <key name="DisplayFilter" value="false" />
  </options>
</grid>

In the C#, I have:

protected void Page_Load(object sender, EventArgs e)
{
    usProducts.UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound;
}

protected object UniGrid_OnExternalDataBound(object sender, string sourceName, object parameter)
{
    switch (sourceName.ToLowerCSafe())
    {
        case "product":
            {
                string _skuID = ValidationHelper.GetString(parameter, "");
                if (String.IsNullOrEmpty(_skuID)) { return null; }
                string product = "";
                foreach (DataRow r in naProducts.Rows)
                {
                    if (r["NodeSKUID"].ToString() == _skuID)
                    {
                        product = r["ProductDisplayName"].ToString();
                        if (String.IsNullOrEmpty(product))
                        {
                            product = r["ProductName"].ToString();
                        }
                    }
                }
                product = product.Replace("<br />", " - ");
                return product;
            }
    }
    return null;
}

I can Response.Write(product) right there before "return product;" and see that it has the right value, but the UniGrid on the page never shows the output in that column - it is blank.

Code very similar to this works on another page with just a UniGrid, but this doesn't seem to work on this UniSelector's UniGrid. What am I missing?

Thanks!

Recent Answers


David te Kloese answered on January 6, 2016 15:47

Hi,

Have you tried a ReloadData() on your grid?

David

1 votesVote for this answer Mark as a Correct answer

Delford Chaffin answered on January 6, 2016 15:50

I had not, but I added:

usProducts.UniGrid.ReloadData();

... to the end of my Page_Load event and it didn't help.

0 votesVote for this answer Mark as a Correct answer

David te Kloese answered on January 6, 2016 16:27

Hi,

can you try adding it before the return of the UniGrid_OnExternalDataBound.

David

0 votesVote for this answer Mark as a Correct answer

Delford Chaffin answered on January 6, 2016 16:32

Yeah, that performed about as I expected (i.e. created an infinite loop).

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on January 6, 2016 17:45

Is this in a webpart or on a page template? If in a webpart, assign your OnExternalDataBound event to the grid in the OnContentLoaded event.

0 votesVote for this answer Mark as a Correct answer

Delford Chaffin answered on January 6, 2016 20:38

This is in a User Control. Here is the whole contents of the .ascx page:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="NatAltDealerProducts.ascx.cs" Inherits="nla_custom_NatAltDealerProducts" %>
<%@ Register src="~/CMSAdminControls/UI/UniSelector/UniSelector.ascx" tagname="UniSelector" tagprefix="cms" %>

<cms:UniSelector ID="usProducts" runat="server" ObjectType="ecommerce.sku" SelectionMode="Multiple" />

I tried to move the event binding to the Page_Unload event to no avail. The .ascx.cs page includes the event handler above, a couple properties and a Page_Load event that sets up the UniSelector as such:

usProducts.WhereCondition = "SKUSiteID = 2 AND SKUEnabled = 1 AND SKUOptionCategoryID IS NULL";
usProducts.OrderBy = "SKUName ASC";
usProducts.ReturnColumnName = "SKUID";
usProducts.DynamicColumnName = true;
usProducts.GridName = "~/nla/custom/NatAltProductGrid.xml";
usProducts.AdditionalColumns = "SKUName,SKUNumber";
usProducts.SelectItemPageUrl = "~/nla/custom/NatAltDealerProductSelectionDialog.aspx";
usProducts.UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound;
0 votesVote for this answer Mark as a Correct answer

Jennifer Brownz answered on December 6, 2017 10:14

My thanks to both Trevor and Brenden! That document was exactly what I was looking for. I trust Kentico security, but I just don't want to include sa username and password in my connection strings! :D download any soundcloud to mp3 track, read Kissmanga chapters for free

0 votesVote for this answer Mark as a Correct answer

chirag panikar answered on February 21, 2018 14:10

free 720p movies download sites are aware how amazing Kodi is when it comes to multimedia services. It enables us to explore the world of entertainment with ease. The best part about Kodi is its ability to work with add-ons. Add-ons work like the extension for Kodi. They improve its capacity. By default Kodi comes with a limited add-on that just helps Kodi to shape its usability but to get the best experience, it is imperative to select the best possible addon that suits your need. There are multiple add-ons available in the market 123movies download 2018 tive to Fusion Kodi?

A3. Scroll down to read the detailed guide about Fusion Kodi Alternatives

Q4. If options are available then why should I use Fusion Kodi?

A4. Fusion Kodi is the best and most popular add-on in this category and is very safe to use.

ll your favorite TV programs, movies and sports events with ultimate privacy and luxury.

acestream para mac os x kickass torrent proxy script netflix free account username and password 2018 extra torrent movies 35 category s cobra radar detector manuals

0 votesVote for this answer Mark as a Correct answer

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