Solved

Grid View control + Colum sorting

Posted on 2010-11-30
6
369 Views
Last Modified: 2012-08-13
I have a Grid View control with coming from multiple tables, and i need to sort different columns which are being displaced indirectly  by Grid View control.
Indirectly means,  these columns are included in the "Datamember" of GridView control as foreign keys. and these fields are populated in the Grid View control  via this foreign key.

How to srt this kind of Grid view control--
0
Comment
Question by:Ammar Iqbal
6 Comments
 
LVL 29

Expert Comment

by:Kumaraswamy R
Comment Utility
0
 
LVL 1

Author Comment

by:Ammar Iqbal
Comment Utility
i have looked into these links. these are not helpful for my requirment. i have cloumns conatained in my grid view coming from differnet tables. I want to sort in a way all records with respect to that column are sorted.
At the moment If i click on the Header of any column, then  only that column is sorted , not the whole grid view control
0
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 250 total points
Comment Utility
I believe you may try to sort your underlying DataTable (which you get as a result of an SQL request, e.g.). Something like:

// Sorting DataTable
DataView dataView = new DataView(dTable);
dataView.Sort = " AutoID DESC, Name DESC";
foreach (DataRowView view in dataView)
{
Response.Write(view["Address"].ToString());
}

See http://www.dotnetfunda.com/articles/article131.aspx for more details
0
 
LVL 7

Assisted Solution

by:kovilpattiBalu
kovilpattiBalu earned 250 total points
Comment Utility

<asp:datagrid id="dgSam" runat="server" AllowCustomPaging="True" AllowPaging="True" AutoGenerateColumns="False"
      AllowSorting="True" EditAllRequired="True" AddRequired="True" DataKeyField="UserID" onadd="dgSam_Add" onupdate="dgSam_Update" onclear="dgSam_Clear" oncancel="dgSam_Cancel" oneditall="dgSam_EditAll">
      <PagerStyle Position="TopAndBottom"></PagerStyle>
      <EditItemStyle CssClass="HeaderFooter"></EditItemStyle>
      <Columns>
            <xnet:BoundColumn SortBehavior="None" DataField="ID" SortExpression="U.ID ASC" ReadOnly="True"
                  SortDescendingExpression="U.ID DESC" HeaderText="ID"></xnet:BoundColumn>
            <xnet:BoundColumn SortBehavior="None" DataField="CompanyName" SortExpression="C.Name ASC" ReadOnly="True"
                  SortDescendingExpression="C.Name DESC" HeaderText="Company "></xnet:BoundColumn>
            <xnet:BoundColumn SortBehavior="None" DataField="UserName" SortExpression="Us.UName ASC" SortDescendingExpression="Us.UName DESC"
                  HeaderText="Member ID"></xnet:BoundColumn>
            <xnet:BoundColumn SortBehavior="None" DataField="FullName" SortExpression="Us.LName ASC" ReadOnly="True"
                  SortDescendingExpression="Us.LName DESC" HeaderText="Name"></xnet:BoundColumn>
            <xnet:BoundColumn SortBehavior="None" DataField="Email" SortExpression="Us.Email ASC" SortDescendingExpression="Us.Email DESC"
                  HeaderText="Email Address">
                  <ItemStyle Wrap="False"></ItemStyle>
            </xnet:BoundColumn>
            <xnet:BoundColumn SortBehavior="None" DataField="SchemaName" ReadOnly="True" HeaderText="User Type "></xnet:BoundColumn>
            
            
      </Columns>
</asp:datagrid>
0
 
LVL 19

Expert Comment

by:Amandeep Singh Bhullar
Comment Utility
This question has been classified as abandoned and is being closed as part of the Cleanup Program. See my comment at the end of the question for more details.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now