Basic coding query - How to set up ascx page to accommodate data retrieval bits?

Last post 02-02-2006 9:20 PM by robaxx. 4 replies.

Sort Posts:

  • Basic coding query - How to set up ascx page to accommodate data retrieval bits?

    01-26-2006, 11:39 PM
    • Participant
      1,415 point Participant
    • robaxx
    • Member since 09-04-2004, 5:14 PM
    • New Zealand
    • Posts 283

    Hi all,

    I know very little about the code behind so bare with me on this.

    I'm busy mucking around with a module's ascx.. the only way I know how to get it to look and work right in my site.

    This particular ascx file has a few bits of code for pulling out data and displaying data as follows:
    <%# DataBinder.Eval(Container.DataItem, "Name") %>

    In another ascx file belonging to the same module, there is a bit that refers to a different field:
    <%# DataBinder.Eval(Container.DataItem, "Description") %>

    Now.. I want to use that second bit in my first ascx file.

    Simply going ahead and using it returns an error; as if the ascx page needs to be warned in advance to expect this item. (I know how these things work in general, but I'm not familiar with the detail and actual syntax)

    So the question is:
    What do I need to add to this ascx file in order to be able to make use of these other, related data retrieval bits? I'm guessing I need to register something in the head?.. but what exactly would that look like?

    Thanks heaps for any pointers :)

     

     

  • Re: Basic coding query - How to set up ascx page to accommodate data retrieval bits?

    01-27-2006, 3:46 AM
    • Member
      315 point Member
    • isomies
    • Member since 04-01-2005, 8:41 AM
    • Posts 63

    You could post the full code, that would make it easier.

     

    Chances are the datasource you have that shows the name field doesn't have the description field. 

  • Re: Basic coding query - How to set up ascx page to accommodate data retrieval bits?

    02-02-2006, 4:54 PM
    • Participant
      1,415 point Participant
    • robaxx
    • Member since 09-04-2004, 5:14 PM
    • New Zealand
    • Posts 283

    Ok, I'll try and reduce it to the bits that matter:

    In this case it is the Free Resource Directory module and its associated FRD TopList (for displaying latest resources).  I often want to do the same thing with other modules... pull data out and make use of it, so I'm hoping to learn the basics on how to do this. I do know the data is in there because it is used elsewhere.

    So.. this is the Directory's RRListEntries.ascx file. It lists the items in the directory.

    It has this at the top:
    <%@ Control Language="c#" AutoEventWireup="false" Codebehind="RRListEntries.ascx.cs" Inherits="Dnn.Hispano.Repository.RRListEntries" TargetSchema="
    http://schemas.microsoft.com/intellisense/ie5"%>


    Further down throughout the HTML, it makes use of these bits:
    <%=GetPageID()%>
    <%=TotalPages%>
    <%=TotalRecords%>
    <%#DataBinder.Eval(Container.DataItem, "PageURL")%>
    <%#DataBinder.Eval(Container.DataItem, "PageNum")%>
    <%# DataBinder.Eval(Container.DataItem, "EntryURL") %>
    <%# DataBinder.Eval(Container.DataItem, "Name") %>
    <%# DataBinder.Eval(Container.DataItem, "WebURL") %>
    <%# DataBinder.Eval(Container.DataItem, "Author") %>

    and many more including:
    <%# DataBinder.Eval(Container.DataItem, "Description") %>

    Now.. there is a related module packaged with FRD, the FRD Top List. This module presumably draws on the same data because it is  used to display details about the very same items.

    This Top List module has this in the header of RRTopView.ascx:
    <%@ Control Language="c#" AutoEventWireup="false" Codebehind="RRTopView.ascx.cs" Inherits="Dnn.Hispano.Repository.FRDTopList.RRTopView" TargetSchema="
    http://schemas.microsoft.com/intellisense/ie5" %>

    And further down it has a couple of the same code bits as the other file above:
    <%# DataBinder.Eval(Container.DataItem, "EntryURL") %>
    <%# DataBinder.Eval(Container.DataItem, "Name") %>

    The question is:
    How can I also make use of
    <%# DataBinder.Eval(Container.DataItem, "Description") %>
    in this file as well?

    A wild guess would be that I need to add something in the header there to let the module know where to find the Description data.

    Any tips are much appreciated.

    Rob

     

  • Re: Basic coding query - How to set up ascx page to accommodate data retrieval bits?

    02-02-2006, 6:13 PM
    • Member
      380 point Member
    • lomaxx
    • Member since 04-19-2005, 12:27 AM
    • Wollongong
    • Posts 76

    Ok rob, so basically what is happening is you have probably got a repeater, in the asxc file. What is actually happening tho, is in the codebehind file RRTopView.ascx.cs There's probably a function that is being set as the Datasource to the repeater. That function may return a simple dataset, or a complex object. If it returns a simple dataset, all you need to do is go into the stored procdure that is supplying the data and get it to select an extra field. If its returning a complex data set then unless you have the source its going to be quite tricky.

    Let me know if you have the source and access to the stored procs and that way we can determine the best way to go from there...

  • Re: Basic coding query - How to set up ascx page to accommodate data retrieval bits?

    02-02-2006, 9:20 PM
    • Participant
      1,415 point Participant
    • robaxx
    • Member since 09-04-2004, 5:14 PM
    • New Zealand
    • Posts 283

    Confused [8-)] .....ooooookay

    heh. umm... this might have to become my first foray into messing with source. I guess it had to come eventually.

    The source for Free Resource Directory and the Top List sidekick module is available, with the usual dnn registration... over here:
    http://www.dnnfreemodules.com/Projects/FreeResourceDirectory/tabid/62/Default.aspx

    I've got it downloaded, but I really haven't the faintest idea where to go from here. I've got Web Developer Express installed with the whole kit and kaboodle if I need it. Do I need to install the DNN starterkit to be able to open up this module or can I just upload changes to my installed copy on my webhost?

    Thanks heaps for any further assistance and pointers

    Rob

Page 1 of 1 (5 items)