Microsoft Content Management Server - DropDownPH Control

This is Interesting: Free IT Magazines  
Home > Archive > Microsoft Content Management Server > February 2007 > DropDownPH Control





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author DropDownPH Control
mullkv@googlemail.com

2007-02-19, 1:15 pm

Hi Everyone,

We are using the DropDownPH Control and all seems well until we
execute the Save.

The error: Object reference not set to an instance of an object

is returned from the line:

((HtmlPlaceholder)this.BoundPlaceholder).Html =
this.ddlAuthoringControl.SelectedItem.Text;

The problem being that the this.ddlAuthoringControl.SelectedItem.Text
is set to null at this point.

The control works fine during edit etc, it's just during Save or
Save&Exit we have the problem.

The code to populate the Items adds them like this:

foreach (DataRow r in dsAssetType.AssetType.Rows)
{
ListItem li = new ListItem();
li.Text = r["Type"].ToString();
li.Value = r["Type"].ToString();
this.hpdFactsType.AllowedValues.Add(li);
}
(Which is working fine).

This code runs in the Page_Load.

I'm guessing the Save event is not having access to the Page_load code
that populates the drop down, and so the list is blank during the
save.....

Any ideas or are we doing something wrong?

many Thanks

Kevin

Stefan Goßner [MSFT]

2007-02-19, 1:15 pm

Hi,

please do some debugging and check if the Page_Load event fires before the
code that accesses the collection.
If the events are fired in different order it might cause such problems.

Cheers,
Stefan


<mullkv@googlemail.com> wrote in message
news:1171901238.302120.44180@j27g2000cwj.googlegroups.com...
> Hi Everyone,
>
> We are using the DropDownPH Control and all seems well until we
> execute the Save.
>
> The error: Object reference not set to an instance of an object
>
> is returned from the line:
>
> ((HtmlPlaceholder)this.BoundPlaceholder).Html =
> this.ddlAuthoringControl.SelectedItem.Text;
>
> The problem being that the this.ddlAuthoringControl.SelectedItem.Text
> is set to null at this point.
>
> The control works fine during edit etc, it's just during Save or
> Save&Exit we have the problem.
>
> The code to populate the Items adds them like this:
>
> foreach (DataRow r in dsAssetType.AssetType.Rows)
> {
> ListItem li = new ListItem();
> li.Text = r["Type"].ToString();
> li.Value = r["Type"].ToString();
> this.hpdFactsType.AllowedValues.Add(li);
> }
> (Which is working fine).
>
> This code runs in the Page_Load.
>
> I'm guessing the Save event is not having access to the Page_load code
> that populates the drop down, and so the list is blank during the
> save.....
>
> Any ideas or are we doing something wrong?
>
> many Thanks
>
> Kevin
>



mullkv@googlemail.com

2007-02-19, 1:15 pm

On 19 Feb, 16:24, "Stefan Go=DFner [MSFT]"
<stef...@online.microsoft.com> wrote:
> Hi,
>
> please do some debugging and check if the Page_Load event fires before the
> code that accesses the collection.
> If the events are fired in different order it might cause such problems.
>
> Cheers,
> Stefan
>
> <mul...@googlemail.com> wrote in message
>
> news:1171901238.302120.44180@j27g2000cwj.googlegroups.com...
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> - Show quoted text -


Hi Stefan,

Thanks for the reply.

The code to populate the drop down is executed fully on entering
"Edit" mode via the Authoring Console.

When I click Save (or Save and Exit),the code first steps into the
Custom PH code and seems to have a problem on the line: for (int i =3D
0; i < _AllowedValues.Count; i++) (It apears that _AllowedValues is
null at this point).

So, at this point it has not re-run the loading of the drop-down list,
so it probably is empty.

I guess the answer is to get the list populated sometime during the
save event (or saving) ....I've tried putting the populating code in
the Saving evet of the placeholder itself, but no luck I'm afraid...!

Many Thanks

Kevin Mullins

mullkv@googlemail.com

2007-02-19, 1:15 pm

On 19 Feb, 16:32, "mul...@googlemail.com" <mul...@googlemail.com>
wrote:
> On 19 Feb, 16:24, "Stefan Go=DFner [MSFT]"
>
>
>
>
>
> <stef...@online.microsoft.com> wrote:
>
the[vbcol=seagreen]
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Hi Stefan,
>
> Thanks for the reply.
>
> The code to populate the drop down is executed fully on entering
> "Edit" mode via the Authoring Console.
>
> When I click Save (or Save and Exit),the code first steps into the
> Custom PH code and seems to have a problem on the line: for (int i =3D
> 0; i < _AllowedValues.Count; i++) (It apears that _AllowedValues is
> null at this point).
>
> So, at this point it has not re-run the loading of the drop-down list,
> so it probably is empty.
>
> I guess the answer is to get the list populated sometime during the
> save event (or saving) ....I've tried putting the populating code in
> the Saving evet of the placeholder itself, but no luck I'm afraid...!
>
> Many Thanks
>
> Kevin Mullins- Hide quoted text -
>
> - Show quoted text -


Hi Again Stefan,

I've managed to fix the problem by executing the populating code in
the _InitializePlaceholderBinding event of the DropDown (makes
sense).... not sure why I hadn't tried that before to be honest.

Thanks for the help.

Kevin

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com