ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

Rearranging one item within a dataset

(1/1)

h0meopathic:
I've got a list of people coming in from a stored procedure alphabetically, stored in a dataset, bound to a custom datasource, then displayed in the order that they came in

on.
--- Code: C# ---protected void gvPhotoGrid_OnItemDataBound(object sender, DataListItemEventArgs e)    {        if (e.Item.ItemType == ListItemType.AlternatingItem | e.Item.ItemType == ListItemType.Item)        {            Label l = (Label)e.Item.FindControl("lblTitle");                        if (l != null)            {                string strval = l.Text;                string title = _title;                 if (title == strval)                {                    l.Text = "";                    e.Item.Visible = false;                }                else                {                    title = strval;                    _title = title;                    l.Text = "<br/>" + title;                    e.Item.Visible = true;                }            }        }    }
My problem is, two people got a divorce and can't be next to each other. They both have the same last name so by default they would come in to the list right next to each other. So, what would be the logic to display one of the people on the list in a different location without putting them at the bottom or top?


--- Code: HTML ---<asp:DataList ID="gvPhotoGrid" runat="server">                <ItemTemplate>                <tr id='<%# Eval("DiaLevelName") %>' align="center">                    <td colspan="2"><asp:Label ID="lblTitle" Font-Underline="true" Font-Bold="true" runat="server" Text='<%# Bind("DiaLevelName") %>' Visible="true" ></asp:Label>                    <br />                    <br />                    </td>                </tr>                <tr align="center">                    <td><a href='<%# ResolveUrl("gemProfile.aspx?gemid=" + Eval("userID") + "&Name=" + Eval("calendarSearch")) %>'>                                        <asp:Image BorderWidth="0px" ID="Image1" runat="server" AlternateText='<%# Eval("userName") %>'                                                     ImageUrl='<%#  ResolveUrl("~/images/gemImages/" + Eval("gemImage")) %>' />                                    </a>                                    <br />                                    <asp:Label runat="server" ID="lblName" Text='<%# Eval("userName") %>' />                                    <br />                                    <br />                    </td>                </tr>                </ItemTemplate>                </asp:DataList>

CWuestefeld:
First, tell those two people to grow up. They can still acknowledge that their previous partner is human. And letting their personal life and professional life overlap (if that's what's happening) is a recipe for problems.

Second, Having to break the natural alphabetic ordering is going to make the application more difficult for everyone else to use.

Third, why not sort by first name instead? Is there any other meaningful sort criteria?

Navigation

[0] Message Index

Go to full version