?
Solved

Grid View control + Colum sorting

Posted on 2010-11-30
6
Medium Priority
?
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
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 30

Accepted Solution

by:
anarki_jimbel earned 1000 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 1000 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

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 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