locked
Templated List mobile control RRS feed

  • Question

  • User1992647513 posted

    Hi, i want to make a custom control that extend the list mobile control to display a grid (like gridview) in the case that the browser support Html32. I wrote a class (XGridViewHtml32) that implement the ITemplate interface and a class (XGridView) that extend the List control and use the template. the problem that I have is that the DataBinding event is called too time so I have a grid's elements duplicated. the result is 2 header, 2 footer and the cells duplicated by the number of row in the datasource. If the datasource contains 2 row the grid will have cell1,cell1 and cell2,cell2, if the datasource contains 3 row the grid will have cell1,cell1,cell1 and cell2,cell2,cell2 and cell3,cell3,cell3 what is wrong in my code? thanks in advance for any response Stefano Here is the source code....

    //**********************************************************************
    // XGRIDVIEW HTML32
    //
    void XGridViewHtml32::InstantiateIn(Control^ container)
    {
        Panel^ l = gcnew Panel();
        l->DataBinding += gcnew EventHandler(this,&XGridViewHtml32::Panel_OnDataBinding);
        container->Controls->Add(l);
    }

    void XGridViewHtml32::Panel_OnDataBinding(Object^ sender, EventArgs^ e)
    {
        Panel^ pPan = dynamic_cast(sender);
        if(strWhichTemplate == Constants::HeaderTemplateTag)
        {
            //return literal control with html table elements CreateHeader(pPan);
        }
        if(strWhichTemplate == Constants::ItemTemplateTag)
        {
            //return literal control with html table elements CreateItem(pPan);
        }
        else if(strWhichTemplate == Constants::FooterTemplateTag)
        {
            //return literal control with html table elements CreateFooter(pPan);
        }
    }

    //**********************************************************************
    // XGRIDVIEW
    //
    void XGridView::OnInit (EventArgs^ e)
    {
        System::Web::UI::MobileControls::DeviceSpecific^ devSpecific =
            gcnew System::Web::UI::MobileControls::DeviceSpecific();
        // Create the choice tag. System::Web::UI::MobileControls::DeviceSpecificChoice^ devChoice =
            gcnew System::Web::UI::MobileControls::DeviceSpecificChoice();
        devChoice->Filter = "isHTML32";
        // Create the HEADER template.
        ITemplate^ m_pHeaderTempl = gcnew XGridViewHtml32(Constants::HeaderTemplateTag);
        devChoice->Templates->Add(Constants::HeaderTemplateTag, m_pHeaderTempl);
        // Create the ITEMS template.
        ITemplate^ m_pItemsTempl = gcnew XGridViewHtml32(Constants::ItemTemplateTag);
        devChoice->Templates->Add(Constants::ItemTemplateTag, m_pItemsTempl);
        // Create the FOOTER
        template. ITemplate^ m_pFooterTempl = gcnew XGridViewHtml32(Constants::FooterTemplateTag);
        devChoice->Templates->Add(Constants::FooterTemplateTag, m_pFooterTempl);
        // Create the tree.
        ((IParserAccessor^)devSpecific)->AddParsedSubObject(devChoice);
        ((IParserAccessor^)this)->AddParsedSubObject(devSpecific);
        __super::OnInit(e);
    }

    Friday, July 7, 2006 4:35 AM

All replies

  • User1625204979 posted
    If you set a breakpoint in your databinding event, can you see what the callstack looks like in the two calls and see if there is anything suspcious there?
    Friday, July 14, 2006 4:37 PM
  • User1992647513 posted

     this is the call stack of the first call to DataBinding Event
    CSystem.Web.csxMobileObjects.DLL!CSystem::Web::Mobile::XGridViewHtml32::Panel_OnDataBinding(System::Object^ sender = 0x00dc48c8, System::EventArgs^ e = 0x006bf34c) Line 189	C++
    [External Code]	
    CSystem.Web.csxMobileObjects.DLL!CSystem::Web::Mobile::XGridView::CreateTemplatedUI(bool doDataBind = true) Line 71	C++
    [External Code]	
    App_Web_hrkosneo.dll!Liste.Page_Load(Object sender = {ASP.magazzino_pickinglist_aspx}, System.EventArgs e = {System.EventArgs}) Line 20 + 0x16 bytes	Basic
    [External Code]	
    

      this is the call stack of the second call to DataBinding Event

    CSystem.Web.csxMobileObjects.DLL!CSystem::Web::Mobile::XGridViewHtml32::Panel_OnDataBinding(System::Object^ sender = 0x00d68460, System::EventArgs^ e = 0x006bf3b8) Line 193	C++
    [External Code]	
    App_Web_hrkosneo.dll!Liste.Page_Load(Object sender = {ASP.magazzino_pickinglist_aspx}, System.EventArgs e = {System.EventArgs}) Line 20 + 0x16 bytes	Basic
    [External Code]	
    

     in Page-Load I call

            m_list.DataSource = pPrelievo
            m_list.DataBind()
    

     the first call is from the CreateTemplatedUI , the second is directly from the DataBind of the page_Load

    I don't undertand this behaviour, Any help woul be appreciated!

    Wednesday, July 19, 2006 4:43 AM
  • User1625204979 posted
    I presume you are using Visual Studio to debug and collect the call stack.  Can you uncheck the option through the menu "Options->Debugging->Enable Just My Code" and get the call stack again?  This will show the callstack in the System.Web.dll and System.Web.Mobile.dll that would help to tell the flow of the calls.
    Friday, July 21, 2006 7:18 PM