How do I do a details class the CSLA (not a child item)

How do I do a details class the CSLA (not a child item)

Old forum URL: forums.lhotka.net/forums/t/1850.aspx


jspurlin posted on Monday, November 27, 2006

I would like to manage details for an item, as I normally do, by formatting a NavigateUrl based on the PrimaryKey datakey that redirects the user to a details page.

In this scenario I have a read only List that returns minimal user data

[Serializable()]
    public class ResourceList :
      ReadOnlyListBase<ResourceList, BasicResource>

When the grid is loaded, each item row has a link to a details page based on the primary key (the syntax may seem strange to one not yet familiar with Telerik controls):

if (!e.Item.IsInEditMode)
        {
            if (e.Item is GridDataItem)
            {
                string IdString = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["PersonId"].ToString();

                StringBuilder sb = new StringBuilder();
                sb.Append("?PersonId=");
                sb.Append(IdString);

                System.Web.UI.WebControls.HyperLink link = e.Item.FindControl("DetailLink") as System.Web.UI.WebControls.HyperLink;
                if (link != null)
                {
                    link.NavigateUrl = SecureQuery("ResourceDetail.aspx", sb.ToString());
                }
            }
        }

When the details link is clicked, the user goes to a details page. This is nothing new. I would like to know if any have suggestions on the best way to handle details, and how they would handle a details class in this case.

My rationale is that since you can load hundreds of users (this Grid is for administrative searching), it makes sense only to load  a read-only list<T> and go ahead and may the round trip to fetch details on a need to know basis, and not have that extra overhead of details not relevant to my search.

What is recommended for the details class?  For example, I could create a details class with read and write properties, public access modifiers and do this (pseudo-code)

On Update

MyDetail.PersonId = txtPersonId.Text;
MyDetail.FirstName = txtFirstName.Text;

I would prefer to databind via the CSLA:DataSource control and map the values instead.

Any suggestions would be appreciated.
Thank you.

RockfordLhotka replied on Tuesday, November 28, 2006

The details object should almost certainly inherit from BusinessBase, and would be a normal editable root object.

I do something quite similar to what you describe in the book. Check out the ProjectEdit.aspx page as discussed in Chapter 10.

Copyright (c) Marimer LLC