Re: Invalid FORMATETC structure (Exception from HRESULT: 0x80040064(DV_E_FORMATETC))



"Neil Ni" <v-neilni@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:Jdc137kJGHA.3152@xxxxxxxxxxxxxxxxxxxxxxxx
> Do you build a custom web control and when you drag and drop this control
> from toolbox, it displayed that error?

Yes

> It seems that something incorrect in your custom web control.

That's why I ask for help here

> Here is an good article for your reference:
>
> "Creating a Web Custom Control"
> http://www.15seconds.com/issue/040421.htm


I'm using VS.Net 2005 I've created a class library it has two classes, here
is the code:

Basket.cs:
---
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
namespace OFiR.Web.Controls
{
[ParseChildren(true)]
class Basket : Control, INamingContainer
{
private ITemplate _headerTemplate = null;
[TemplateContainer(typeof(BasketHeader))]
public ITemplate Header
{
get
{
return _headerTemplate;
}
set
{
_headerTemplate = value;
}
}
// override to prevent literal controls from being added as children
protected override void AddParsedSubObject(object o)
{
}
protected override void CreateChildControls()
{
if (Header != null)
{
// create header
BasketHeader basketHeader = new BasketHeader();
// initialize header from template
Header.InstantiateIn(basketHeader);
// add header to the child controls collection
Controls.Add(basketHeader);
basketHeader = new BasketHeader();
// initialize header from template
Header.InstantiateIn(basketHeader);
// add header to the child controls collection
Controls.Add(basketHeader);
}
}
}
}
---
BasketHeader.cs
---
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
namespace OFiR.Web.Controls
{
class BasketHeader : Control, INamingContainer
{
}
}
---


As you can see it's some very simple classes, and for some reason I get an
error when I try to drag and drop them onto my aspx page.

I've tried to create a new class library and start from scratch with the
same two classes but the same error occurs.

I've also tried the "Developing a Templated Databound Control" Example
described here:
http://samples.gotdotnet.com/quickstart/aspplus/default.aspx?url=%2fquickstart%2faspplus%2fdoc%2fwebctrlauthoring.aspx

The above example has almost identical code, and that control works
correctly, I simply can't spot the difference that produces the error, and I
don't find the error raised very informative. What causes the "Invalid
FORMATETC structure" error?

Can someone please help?

Kind Regards,
Allan Ebdrup


.



Relevant Pages

  • Invalid FORMATETC structure (Exception from HRESULT: 0x80040064(DV_E_FORMATETC))
    ... class Basket: Control, INamingContainer ... public ITemplate Header ... protected override void CreateChildControls() ... BasketHeader header = new BasketHeader; ...
    (microsoft.public.dotnet.framework.aspnet.webcontrols)
  • Re: Combobox Display Problem
    ... Header section of the Sub-form, and it was invisible when run as I mentioned. ... ' Find the record that matches the control. ... Header section of the form (subform), ... The Control Source for cboItem on fsubGroup is chrItem, ...
    (microsoft.public.access.forms)
  • Re: ToolTipText and the ListView control in VB6
    ... control setup. ... '* Description: Process MouseMove event. ... If .ToolTipText objListItem.Key Then ... '' the mouse must be in the header area. ...
    (microsoft.public.vb.controls)
  • Re: Another GridView Bug -> PagerSettings.Visible
    ... GridView control is based on templates ... stage is the only time you can build the control structure. ... set to true and capture the pager row ... note that the header should be enabled when the pager is visible and ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Blank Lines in report
    ... Asset Finance Fraud Forum ... The header finishes after "Distributed to Group List" ... > Duane Hookom ... >> I have a report that has a header for one control and the detail showing ...
    (microsoft.public.access.reports)