Solved

Grid View control + Colum sorting

Posted on 2010-11-30
6
380 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 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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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