This is a migrated thread and some comments may be shown as answers.

Sort RadListView by a specified column(column value is stored in literal control)

1 Answer 81 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Sakshi
Top achievements
Rank 1
Sakshi asked on 28 Jun 2012, 04:22 AM
Hi Everyone,

I have my RadListView as below:

telerik:RadListView ID="rlvContentDisplay" runat="server"

        AllowPaging="True"

        AllowSorting="True"

        BorderStyle="None"

        GridLines="None"   

        DataKeyNames="PropertyID"

        ItemPlaceholderID="DashboardPlaceHolder"

        OnItemDataBound="rlvContent_ItemDataBound"

        OnNeedDataSource="rlvContent_NeedDataSource"

        ItemCommand = "rlvContent_ItemCommand"

        Width="100%">

        <LayoutTemplate>

<div id="assetIndex">

     <div class="expand"></div>

     <div id="DashboardPlaceHolder" runat="server"></div>            

     <telerik:RadDataPager ID="rdpContent" CssClass="dashboardPaginate" runat="server"PagedControlID="rlvContentDisplay" PageSize="15" BorderStyle="None" Width="700"EnableEmbeddedSkins="false" Skin="RadSkin">

               <Fields>

                 <telerik:RadDataPagerPageSizeField PageSizeText="Results per page" />

                 <telerik:RadDataPagerGoToPageField CurrentPageText="Page:"TotalPageText="of" SubmitButtonText="" TextBoxWidth="25" />

                  <telerik:RadDataPagerButtonField FieldType="NextLast" />

                  <telerik:RadDataPagerButtonField FieldType="Numeric" />  

                  <telerik:RadDataPagerButtonField FieldType="FirstPrev" />

                </Fields>

                </telerik:RadDataPager>

            </div>

           </LayoutTemplate>   

        <ItemTemplate>

            <div id="contentHold_<%# Convert.ToString(DataBinder.Eval(Container.DataItem, "id"))%>" class="asset max">

                <div>

                    <div class="summary imageContainer toggleDetail" alt="toggle"onclick="toggleDetail(this, <%# Convert.ToString(DataBinder.Eval(Container.DataItem, "id"))%>)"></div>

                    <div class="summary lineContainer">

                           <div id="galleryImageBox" class="galleryImageBox"runat="server">

                            <asp:HyperLink ID="headlineLink" runat="server"><asp:ImageID="storyThumb" runat="server" CssClass="storyThumb" /></asp:HyperLink>

                           </div>

                           <div class="galleryInfoContainer">

                                  <asp:Literal ID="litHeadlineLink" runat="server"></asp:Literal>

                            <div id="abstract_<%#Convert.ToString(DataBinder.Eval(Container.DataItem, "id"))%>" class="detail itemAbstract">

                                <asp:Literal runat="server" ID="litAbstract" />

                            </div>

                                  <div class="byline">By <asp:Literal runat="server"ID="litAuthorInfo" /></div>

                                 

                           </div>

                    </div>

                    <div class="summary sectionContainer"><asp:Literal runat="server"ID="litSectionInfo" /></div>

                    <div class="summary metaContainer">

                        <div class="datetime"><asp:Literal runat="server"ID="litDateStamp" /></div>

                        <span class="fontRed"><asp:Literal runat="server" ID="litMinsAgo"/></span>

                           <div class="user"><asp:Literal runat="server" ID="litLastUser"/></div>                       

                        <div class="status redText"><asp:Literal ID="litStatus"runat="server" Visible="true" /></div>                       

                    </div>

                </div>

            </div>

           

            <div class="asset hrule"></div>

            <div id="asset_<%# Convert.ToString(DataBinder.Eval(Container.DataItem, "id"))%>" class="detail">

                <div style="background-color:#f1f1f1; padding:10px">

                               <asp:Literal ID="litAssetsSlider" runat="server" />

                               <div id="emptyAsset" class="emptyAsset" runat="server"visible="false">

                                      <div class="largeMessage">You have no assets.</div>

                                      <telerik:RadButton ID="btnAddAlbum" runat="server"AutoPostBack="False" BackColor="transparent" ButtonType="LinkButton"UseSubmitBehavior="False"

                                             Text="Add Asset" Title="Add an asset for this Story" EnableEmbeddedSkins="false"

                            Skin="RadSkin" />

                               </div>

                </div>

                     </div>

           

        </ItemTemplate>

    </telerik:RadListView>


In my code behind:

I am binding and changin the value of litSectionInfo as below:

 protected void rlvContent_ItemDataBound(object sender, RadListViewItemEventArgs e)
        {
System.Web.UI.WebControls.Literal litSectionInfo = (System.Web.UI.WebControls.Literal)e.Item.FindControl("litSectionInfo");
                    if (litSectionInfo != null)
                    {
                        LoadStoryKeyValuePairs(thisStory.Metadata.item);
                        if (ArticleKeyValuePairs.ContainsKey("ssts"))
                        {
                            char[] delimiterChars = { '/' };
                            string[] ssts = ArticleKeyValuePairs["ssts"].ToString().Split(delimiterChars, StringSplitOptions.RemoveEmptyEntries);
                            if (ssts.Length > 0)
                            {                                
                                litSectionInfo.Text = char.ToUpper(ssts[0][0]) + ssts[0].Substring(1);
                            }
                        }                       
                        if (thisStory.Handling.publishto != null && thisStory.Handling.publishto.ssts != null)
                        {
                            string sitename = "";
                            if (siteTypes.ContainsKey(thisStory.siteid) && siteTypes[thisStory.siteid][0].ToLower() == "blog")
                            {
                                sitename = siteTypes[thisStory.siteid][1];
                            }
                            else
                            {
                                sitename = thisStory.Handling.publishto.ssts.section;
                            }
                            if (sitename != null) {  litSectionInfo.Text = char.ToUpper(sitename[0]) + sitename.Substring(1); }
                        }
}          }

My Literal control inside the listview displays info correctly.
I have a combobox which holds values section ASC and Section DESC.

How can I sort based on the literal control column data that is displayed in the radlistview?

what value do i need to pass for the expression.FieldName,(example for id, right now i am passing expression.FieldName ="Id", this works because Id is the dataitem ).

Someone please help me figure out this,

Thanks in advance for your help.


1 Answer, 1 is accepted

Sort by
0
Sakshi
Top achievements
Rank 1
answered on 28 Jun 2012, 03:37 PM
Is there no solution for this?

I appreciate if someone can pass me an idea on this.This is driving me crazy, tried multiple ways.


Thanks a lot
Tags
ListView
Asked by
Sakshi
Top achievements
Rank 1
Answers by
Sakshi
Top achievements
Rank 1
Share this question
or