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.0ItemDataBound event: code created automaticallyItemDataBound event: code created automatically
Previous
 
Next
New Post
9/24/2007 9:22 AM
 

Hello everybody,

I've created a new module in DNN4.5.3 (the language I use is C# ). In the View user control this code is automatically inserted for the ItemDataBound event:

string strContent = strTemplate;
string strValue = Null.NullString;

//add content to template
ArrayList objProperties = CBO.GetPropertyInfo(typeof(LMVideoGalleryInfo));
int intProperty;
foreach (PropertyInfo objPropertyInfo in objProperties)

if (strContent.IndexOf("[" + objPropertyInfo.Name.ToUpper() + "]") != -1) 

strValue = Server.HtmlDecode(DataBinder.Eval(e.Item.DataItem, objPropertyInfo.Name).ToString()); 
strContent = strContent.Replace("[" + objPropertyInfo.Name.ToUpper() + "]", strValue); 
}
}

//assign the content
Label lblContent = (Label)e.Item.FindControl("lblContent");
lblContent.Text = strContent;

Can anyone tell me what does this code do? It's very helpful that some code is automatically generated, but I'dlike to know the meaning of this code!

 
New Post
9/26/2007 7:33 PM
 

when u say - autogenerated - what was it autogenerated by ???

Westa

 
New Post
9/27/2007 3:14 AM
 

This code is written by DotNetNuke when you create a module using the module template.

 
New Post
9/27/2007 9:22 AM
 

Hey deven,

This code is simply adding the content to the datalist. This code is sort of sloppy too. It doesn't check to see if the ListItemType even has a DataItem. Here is what I would put into the ItemDataBound event.

if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; }

((Label)e.Item.FindControl("lblContent")).Text = ((string)e.Item.DataItem);

Or say you had an active record pattern that you needed to use such as EmployeeInfo and EmployeeInfo had a property called FullName you could use boxing and unboxing to get this full name on one line of code like this:

((Label)e.Item.FindControl("lblContent")).Text = ((EmployeeInfo)e.Item.DataItem).FullName;

I hope this helps...

BTW, The default C# module has two problems in the SqlDataProvider file. There is a capital I in an 'if' statement and there is an apostrophe used for a comment in the same function.

 

Cheers!


Cheers!
John Valentine
http://www.webinnovationsystems.com
 
New Post
9/28/2007 4:48 AM
 

Thank you very much HisKid for your help!

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0ItemDataBound event: code created automaticallyItemDataBound event: code created automatically


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