Solved

Grid View control + Colum sorting

Posted on 2010-11-30
6
372 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
ID: 34238164
0
 
LVL 1

Author Comment

by:Ammar Iqbal
ID: 34238180
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
ID: 34242550
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
ID: 34256188

<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
ID: 34886507
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

770 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