Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Databinding on ModuleAuditControl with ObjectDataSourceDatabinding on ModuleAuditControl with ObjectDataSource
Previous
 
Next
New Post
12/19/2007 11:53 PM
 

I'm attempting to databind on the CreatedByUser & CreatedDate properties on a ModuleAuditControl using something like this. (This is just an excerpt. I have sucessfully databound on other controls/properties.)

<asp:FormView ID="FormView1" runat="server" DataSourceID="JobOpeningDataSource" DataKeyNames="OpeningID" DefaultMode="Insert">
    <EditItemTemplate>
        <dnn:Audit ID="ctlAudit" runat="server" CreatedByUser='<%# Bind("CreatedByUser") %>' CreatedDate='<%# Bind("CreatedDate") %>'/>
    </EditItemTemplate>
</asp:FormView>

I get this compiler error: The property or indexer 'DotNetNuke.UI.UserControls.ModuleAuditControl.CreatedByUser' cannot be used in this context because it lacks the get accessor

I'm assuming there's a good reason why the CreatedByUser & CreatedDate properties on the ModuleAuditControl only implement a Set and not a Get, but can anyone tell me if I'm missing anything. (I don't completely understand why a Get accessor is needed in the situation anyway. I'm only trying to Set.)

As you can see, I was using an ASP.NET 2.0 ObjectDataSource to retrieve my data object and was doing all of the databinding w/o any code-behind, similar to how Michael Washington did in his example Guestbook module here. Is there a way to bind these properties automatically using an ObjectDataSource, or is this just a situation in which I should scrap the ObjectDataSource and manually implement databinding in the code-behind the way most of the core modules do.

I'm beginning to suspect that using an ObjectDataSource is a quick way to get a module functional, but if you want to implement some more advanced features such as the ModuleAuditControl, you may be better off "manually" databinding in the code-behind (Page_Load event) Am I missing anything? Thoughts?

Thanks in advance.

 
New Post
12/20/2007 9:26 AM
Accepted Answer 

The object data source works well for collections that implement ICollection<(Of <(T>)>). For all other data sources it is best to bind the data manually. 

You can also use the RowDataBound event to insert data, For example in the code below I use it to hide a button on the GridView:

Protected Sub HideEditButtons(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then
ThingsForSaleInfo_data = CType(e.Row.DataItem, ThingsForSaleInfo)
If IsInRole("Administrators") Or (Entities.Users.UserController.GetCurrentUserInfo.UserID = CInt(ThingsForSaleInfo_data.UserID)) Then
e.Row.Cells.Item(0).Enabled = True
Else
e.Row.Cells.Item(0).Text = "&nbsp;"
End If
End If

End Sub

 

 



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
New Post
12/20/2007 10:45 AM
 

Thanks, that's useful information.

Also thanks for all your contributions to the community. Your DNN Help website has been instrumental for me getting started in module development.

 
New Post
12/20/2007 11:49 AM
 

Thank you. I hope to have my latest tutorial complete by next week:

Creating a DotNetNuke Module using LINQ to SQL (in progress)

It uses the Things4Sale module but uses LINQ. This REALLY changes the way I do things now. I mean I can barely look at the old stuff after using LINQ to SQL and the LINQDataSource control.

Microsoft started some great things with the Object Data Source control but really hit a home run with the LinqDataSource control. I mean you can read and write from the database without writing any DAL code!

If you look at the tutorial now I have enough done to show you what I mean.

These are very exciting times in ASP.NET



Michael Washington
http://ADefWebserver.com
www.ADefHelpDesk.com
A Free Open Source DotNetNuke Help Desk Module
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Databinding on ModuleAuditControl with ObjectDataSourceDatabinding on ModuleAuditControl with ObjectDataSource


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out