Site Search:
Sign in | Join | Help
4Penny.net

ComponentArt

  • Populating a ComponentArt grid using linq

    Here is a thread that I had with Component Art support. I have not tested this - I have largely dropped my testing of Linq to sql because of this issue. I have problems with Janus Winform grids also.

    Sirs:

    I'm trying to start using linq in a web form.

     

    I can't get a grid to bind to a resultset that comes from a stored procedure.

    The error that I'm getting is 'Object reference not set to an instance of an object' when databinding.

     

    I see a post that mentions converting the ISINGLERESULT into a Datatable, but can't figure that out.

     

    Can you help?

     

    Hello,

     

    That error isn't what I'd expect to see- are you able to bind this linq query to a standard datagrid?

     

    The error we're aware of is that the grid can't enumerate through a linq data source; thus, something like this:

     

    Grid1.DataSource = from person in people select person; Grid1.DataBind(); 

     

    Fails with a nullreferenceexception. To workaround that, you could do

    this:

     

    var linq = from person in people select person; Grid1.DataSource = linq.ToList(); Grid1.DataBind();

     

    So in your code, set your results to a var type, then cast the type to one the grid can enumerate (a list as above, or a DataTable, etc).

     

    Stephen Hatcher

    Developer Support Manager

    ComponentArt Inc.

     

     

    Sirs:

    Your examples are using standard linq to sql access, I'm using the *stored

    procedure* access.

    Scott Gu demonstrates this here

    http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-ret

    riev

    ing-data-using-stored-procedures.aspx

     

    All my data access is via stored procs.

     

    I'd be happy with the '.tolist' approach, but I can't get a stored procedure result to do that. Can you help?

     

     

     

    Hello,

     

    I see. Unless I'm mistaken (and I very well could be), this article shows you how to do that. Unfortunately it's all images, but take a look at this one:

     

    http://www.scottgu.com/blogposts/linqsproc1/step12.jpg

     

    You can see him casting his proc to a list there. In a previous example, you can see him set the results of his proc to the var type as well:

     

    http://www.scottgu.com/blogposts/linqsproc1/step6.jpg

     

    So you could use that, then use ToList on the var. Does that make sense?

      

    Stephen Hatcher

    Developer Support Manager

    ComponentArt Inc.

     

  • Using resuable content with a ComponentArt Dialog

    I recently wrote in to ComponentArt support on this subject, here is the email thread.  

    Sirs:
    I'd like to be able to somehow templage the Dialog control so that I didnt have so much text on my .aspx page.

    In other words, I'd like to replace everything in the <header> and <footer> areas and somehow populate them from a class.

    Is that at all possible?

    something like:

    Dialog1.header.innerhtml = "<table>...</table>"

     

    Steve,

    The easiest way to do this would be to load controls into the Content in code behind by using:

    Dialog1.Header.Controls.Add(Page.LoadControl("Head1.ascx"));
    Dialog1.Content.Controls.Add(Page.LoadControl("Page1.ascx"));
    Dialog1.Footer.Controls.Add(Page.LoadControl("Foot1.ascx"));

    Just leave your sections empty in the dialog.

    <Header></Header>
    <Content></Content>
    <Footer></Footer>

    Hope this helps.

     

  • Template code for adding a ComponentArt Menu to a site

    Adding a ComponentArt menu to a web site is something that I have to do frequently, here is template code to do that quickly

    Menu code:

    <ComponentArt:Menu id="Menu1"
        ExpandDelay="50"
        DefaultGroupCssClass="Group"
        SiteMapXmlFile="menuData.xml"
        ImagesBaseUrl="images/"
        DefaultItemLookID="DefaultItemLook"
        EnableViewState="false" Width="100%"
        runat="server">
        <ItemLooks>
            <ComponentArt:ItemLook LookID="DefaultItemLook" CssClass="Item" 
                HoverCssClass="ItemH" ExpandedCssClass="ItemExp" LabelPaddingLeft="5" 
                LabelPaddingRight="15" LabelPaddingTop="2" LabelPaddingBottom="2" 
                RightIconUrl="arrow.gif" RightIconWidth="15" RightIconHeight="10" 
                RightIconVisibility="WhenExpandable" />
            <ComponentArt:ItemLook LookID="EdgeLook" CssClass="ItemEdge" />
            <ComponentArt:ItemLook LookID="BreakItem" ImageUrl="break.gif" ImageHeight="1" ImageWidth="100%" />
        </ItemLooks>
    </ComponentArt:Menu>

    Create MenuData.xml like this:

    <SiteMap>
     <item text=" " width="5px" LookID="EdgeLook" />
     <item text="Home" NavigateUrl="Default.aspx"  />
    
    
     <item text=" " width="5px" LookID="EdgeLook" />
     <item text="Photo Album" NavigateUrl="PhotoAlbums.aspx"  />
    
    
     <item text=" " width="5px" LookID="EdgeLook" />
     <item text="Photo Caption Contest" NavigateUrl="PhotoCaptionContest.aspx"  />
    
    
     <item text=" " width="5px" LookID="EdgeLook" />
     <item text=" " width="100%" />
    </SiteMap>

    Then add the .css file:

    .Group
    {
     border:solid 1px black; 
    
    
     background-repeat:repeat;
     background-position:left;
     padding-bottom: 0px;
     padding-top:0px;
     padding-left:2px;
     padding-right: 2px; 
     text-align: center;
     height:22px; 
     vertical-align:middle;
     font-size:12px; 
     color:white;
    
    
    }
    .test { }
    
    
    .ItemEdge
    {
     font-family: verdana;
     background-image :url(/images/menuBG2.gif);
     border:solid 0px black; 
     cursor:pointer;
    }
    .Item
    {
     font-family: verdana;
     background-image :url(/images/menuBG.gif);
     border:solid 0px black; 
     cursor:pointer;
    }
    
    
    .ItemH
    {
     font-family: verdana; 
     background-image :url(/images/menuBG.gif);
     color:silver; 
     border:solid 0px black; 
     cursor:pointer;
    }
    
    
    .ItemExp
    {
      color:black; 
      font-size:12px; 
      border:solid 0px black; 
      cursor:pointer;
    }
    
    
     

More Posts Next page »