473,320 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

datagrid not sorting

Hi

I have a datagrid with bound columns generated in code behind with
allowsorting set to true and OnSortCommand set to a sort function. I can see
the sorted results only if i remove the autogeneratecolumns = false,
otherwise i am not getting the results.
It is not getting to the dgresults_sort function when i clicked on the
column_header link.
Any thing i am missing in my code?

code:
<tr>
<td><asp:datagrid id="dgresults" runat="server"
CssClass="GridHeaderTemplate" GridLines="None" AllowSorting="True"
CellSpacing="1" CellPadding="1"
OnItemDataBound="dgresults_ItemDataBound" OnSortCommand="dgresults_sort"
AutoGenerateColumns =False>
<AlternatingItemStyle
cssclass="GridAlternatingItemTemplate"></AlternatingItemStyle>
<ItemStyle CssClass="GridItemTemplate"></ItemStyle>
<HeaderStyle Font-Size="Smaller" Font-Names="verdana"
BorderWidth="2px" ForeColor="white" BorderStyle="None"
BackColor="Gray"></HeaderStyle>
</asp:datagrid></td>
</tr>

codebehind:
public void dgresults_sort(object sender, DataGridSortCommandEventArgs e)

{

SortField = (string)e.SortExpression;

CreateDataSource();

}
Jun 5 '06 #1
2 1186
Where are your columns defined? Setting AutoGenerateColumns=False
should not display any columns based on the code you've shown. Try
defining a couple of colums on the datagrid.

Curtis

gane wrote:
Hi

I have a datagrid with bound columns generated in code behind with
allowsorting set to true and OnSortCommand set to a sort function. I can see
the sorted results only if i remove the autogeneratecolumns = false,
otherwise i am not getting the results.
It is not getting to the dgresults_sort function when i clicked on the
column_header link.
Any thing i am missing in my code?

code:
<tr>
<td><asp:datagrid id="dgresults" runat="server"
CssClass="GridHeaderTemplate" GridLines="None" AllowSorting="True"
CellSpacing="1" CellPadding="1"
OnItemDataBound="dgresults_ItemDataBound" OnSortCommand="dgresults_sort"
AutoGenerateColumns =False>
<AlternatingItemStyle
cssclass="GridAlternatingItemTemplate"></AlternatingItemStyle>
<ItemStyle CssClass="GridItemTemplate"></ItemStyle>
<HeaderStyle Font-Size="Smaller" Font-Names="verdana"
BorderWidth="2px" ForeColor="white" BorderStyle="None"
BackColor="Gray"></HeaderStyle>
</asp:datagrid></td>
</tr>

codebehind:
public void dgresults_sort(object sender, DataGridSortCommandEventArgs e)

{

SortField = (string)e.SortExpression;

CreateDataSource();

}


Jun 5 '06 #2
I have my columns defined in the createdatasource() function.
The datagrid displays fine on postback on click of a button. But
it is not going to the dgresults_sort method when i clicked on the datagrid
header with results.
i am not calling the createdatasource() in page postback method.
doesn't sortcommand work the same way as button click?
public void dgresults_sort(object sender, DataGridSortCommandEventArgs e)

{

SortField = (string)e.SortExpression;

CreateDataSource();

}

private void btnSearch_ServerClick(object sender, System.EventArgs e)

{

CreateDataSource();

}


"Curtis" <cu**********@hotmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
Where are your columns defined? Setting AutoGenerateColumns=False
should not display any columns based on the code you've shown. Try
defining a couple of colums on the datagrid.

Curtis

gane wrote:
Hi

I have a datagrid with bound columns generated in code behind with
allowsorting set to true and OnSortCommand set to a sort function. I can
see
the sorted results only if i remove the autogeneratecolumns = false,
otherwise i am not getting the results.
It is not getting to the dgresults_sort function when i clicked on the
column_header link.
Any thing i am missing in my code?

code:
<tr>
<td><asp:datagrid id="dgresults" runat="server"
CssClass="GridHeaderTemplate" GridLines="None" AllowSorting="True"
CellSpacing="1" CellPadding="1"
OnItemDataBound="dgresults_ItemDataBound" OnSortCommand="dgresults_sort"
AutoGenerateColumns =False>
<AlternatingItemStyle
cssclass="GridAlternatingItemTemplate"></AlternatingItemStyle>
<ItemStyle CssClass="GridItemTemplate"></ItemStyle>
<HeaderStyle Font-Size="Smaller" Font-Names="verdana"
BorderWidth="2px" ForeColor="white" BorderStyle="None"
BackColor="Gray"></HeaderStyle>
</asp:datagrid></td>
</tr>

codebehind:
public void dgresults_sort(object sender, DataGridSortCommandEventArgs e)

{

SortField = (string)e.SortExpression;

CreateDataSource();

}

Jun 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris Mayers | last post by:
I have a Windows Forms DataGrid that has a DataView as a datasource. My problem is that I want the datagrid to exhibit some special sorting properties when the header rows are clicked on. From...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
1
by: Sargas Atum | last post by:
Hi all, 1. I have a problem with cell selection in a table in a DataGrid. I dont want that anybody writes in the cells. That was not a problem I changed them to "read only", but if I am going...
3
by: melanieab | last post by:
Hi, I'm programatically sorting in a datagrid. When a column header is clicked, the sort happens twice for some reason, making it looks like it only sorts in descending order. I can tell it...
7
by: DC Gringo | last post by:
I have a datagrid that won't sort. The event handler is firing and return label text, just not the sort. Here's my Sub Page_Load and Sub DataGrid1_SortCommand: -------------------- Private...
1
by: Jeremy | last post by:
I want my gird to sort only the items on the current page when I click on a column header. I wrote a little test app, but when I sort it pulls in items from other pages and places them on the current...
4
by: Manny Chohan | last post by:
hi guys, my code is returning an array and i need to create datagrid so that i can have sorting and implement prev....next function on it to navigate. is there any way this can be done in...
5
by: DKC | last post by:
Hi, Using VB.NET. I have a datagrid having a strongly typed array of objects as its data source. The data from the array of objects is displayed by means of a table style, which is fine, but...
1
by: ECD | last post by:
Hello all, I can usually find solutions to my .NET problems by searching these groups, but I'm stumped on this one. I have a datagrid in VB.NET (2.0 framework). I want to disable sorting on...
0
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.