473,325 Members | 2,785 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,325 software developers and data experts.

Can not sort datagrid

Joe
Hello,

I have a datagrid in an nested html table (one table inside of another
table) and have set the allowsSorting property to true. I've created in the
code-behind a method (Sub - I'm using VB.NET) that handles the SortCommand
event of the data grid. I've included the declaration of the Sub below.
EnableViewState is set to false; we reload the DataSource each time the page
posts.

Would anyone know why this DataGrid doesn't sort? The web server isn't
executing the SortCommand event handler.

If tehre is any other information that I can offer, please elt me know.
This really has me stumped.

Sub Declaration:*********************************
Private Sub SortDataGridColumns(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
dgForms.SortCommand

PopulateClaimFormsDataGrid(e.SortExpression,
SwapSortDirection(e.SortExpression))
End Sub
*********************************************

Data Grid HTML**********************************
<asp:datagrid id="dgForms" runat="server" CssClass="Interior"
AllowSorting="True" AutoGenerateColumns="False">
<AlternatingItemStyle
BackColor="GhostWhite"></AlternatingItemStyle> <ItemStyle
BackColor="Gainsboro"></ItemStyle>
<Columns>
<asp:HyperLinkColumn Target="_self"
DataNavigateUrlField="Form_Path_File_NM" DataTextField="Form_Number"
SortExpression="Form_Number" HeaderText="NUMBER">
<HeaderStyle Width="10%" CssClass="TableHeader"></HeaderStyle>
<ItemStyle CssClass="TableData"></ItemStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField="Form_Name" SortExpression="Form_Name"
HeaderText="NAME">
<HeaderStyle Width="50%" CssClass="TableHeader"></HeaderStyle>
<ItemStyle CssClass="TableData"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Description"
SortExpression="Description" HeaderText="CATEGORY">
<HeaderStyle Width="25%" CssClass="TableHeader"></HeaderStyle>
<ItemStyle CssClass="TableData"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Form_State_CD"
SortExpression="Form_State_CD" HeaderText="STATE">
<HeaderStyle Width="15%" CssClass="TableHeader"></HeaderStyle>
<ItemStyle CssClass="TableData"></ItemStyle>
</asp:BoundColumn>
</Columns>
</asp:datagrid>
*********************************************

TIA,

--
Joe

VBA Automation/VB 6/C++/C#/ VB.NET/Web and DB development
Nov 19 '05 #1
4 1496
Jon
We need to see what you do in PopulateClaimFormsDataGrid

You would need to create a DataView and set it Sort property to the
e.SortExpression param you pass then bind the DataGrid to the DataView
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com...
Hello,

I have a datagrid in an nested html table (one table inside of another
table) and have set the allowsSorting property to true. I've created in
the
code-behind a method (Sub - I'm using VB.NET) that handles the SortCommand
event of the data grid. I've included the declaration of the Sub below.
EnableViewState is set to false; we reload the DataSource each time the
page
posts.

Would anyone know why this DataGrid doesn't sort? The web server isn't
executing the SortCommand event handler.

If tehre is any other information that I can offer, please elt me know.
This really has me stumped.

Sub Declaration:*********************************
Private Sub SortDataGridColumns(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
dgForms.SortCommand

PopulateClaimFormsDataGrid(e.SortExpression,
SwapSortDirection(e.SortExpression))
End Sub
*********************************************

Data Grid HTML**********************************
<asp:datagrid id="dgForms" runat="server" CssClass="Interior"
AllowSorting="True" AutoGenerateColumns="False">
<AlternatingItemStyle
BackColor="GhostWhite"></AlternatingItemStyle> <ItemStyle
BackColor="Gainsboro"></ItemStyle>
<Columns>
<asp:HyperLinkColumn Target="_self"
DataNavigateUrlField="Form_Path_File_NM" DataTextField="Form_Number"
SortExpression="Form_Number" HeaderText="NUMBER">
<HeaderStyle Width="10%" CssClass="TableHeader"></HeaderStyle>
<ItemStyle CssClass="TableData"></ItemStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField="Form_Name" SortExpression="Form_Name"
HeaderText="NAME">
<HeaderStyle Width="50%" CssClass="TableHeader"></HeaderStyle>
<ItemStyle CssClass="TableData"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Description"
SortExpression="Description" HeaderText="CATEGORY">
<HeaderStyle Width="25%" CssClass="TableHeader"></HeaderStyle>
<ItemStyle CssClass="TableData"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Form_State_CD"
SortExpression="Form_State_CD" HeaderText="STATE">
<HeaderStyle Width="15%" CssClass="TableHeader"></HeaderStyle>
<ItemStyle CssClass="TableData"></ItemStyle>
</asp:BoundColumn>
</Columns>
</asp:datagrid>
*********************************************

TIA,

--
Joe

VBA Automation/VB 6/C++/C#/ VB.NET/Web and DB development

Nov 19 '05 #2
Joe
Jon,

Sorry for the delay. I do create a dataview. Here's the code:

Private Sub PopulateClaimFormsDataGrid(ByVal OrderBy As String, ByVal
SortDirection As String)

'Retrieve Claim Froms data from database
Dim cForm As New ClaimForm
dtClaimForms = cForm.LoadClaimForms(hdnLineOfBusniessID.Value,
hdnSearchText.Value, hdnSelectedCategory.Value, OrderBy, SortDirection)

'If Claim Forms are found, display sorted data
If dtClaimForms.Rows.Count > 0 Then
Dim dvForms As New DataView
dvForms = dtClaimForms.DefaultView

lblFormMsg.Text = String.Empty
dgForms.DataSource = dvForms
dgForms.DataBind()
Else
lblFormMsg.Text = "Can't locate any forms for the provided data."
ClearClaimsFormsDataGrid()
End If

cForm = Nothing
End Sub
This is not the problem. The SortCommand event is never called. So, this
function doesn't matter. The question is, why is the web server not firing
the SortCommand event for the datagrid....

Thanks,

Joe
--
Joe

VBA Automation/VB/C++/Web and DB development
"Jon" wrote:
We need to see what you do in PopulateClaimFormsDataGrid

You would need to create a DataView and set it Sort property to the
e.SortExpression param you pass then bind the DataGrid to the DataView
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com...
Hello,

I have a datagrid in an nested html table (one table inside of another
table) and have set the allowsSorting property to true. I've created in
the
code-behind a method (Sub - I'm using VB.NET) that handles the SortCommand
event of the data grid. I've included the declaration of the Sub below.
EnableViewState is set to false; we reload the DataSource each time the
page
posts.

Would anyone know why this DataGrid doesn't sort? The web server isn't
executing the SortCommand event handler.

If tehre is any other information that I can offer, please elt me know.
This really has me stumped.

Sub Declaration:*********************************
Private Sub SortDataGridColumns(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
dgForms.SortCommand

PopulateClaimFormsDataGrid(e.SortExpression,
SwapSortDirection(e.SortExpression))
End Sub
*********************************************

Data Grid HTML**********************************
<asp:datagrid id="dgForms" runat="server" CssClass="Interior"
AllowSorting="True" AutoGenerateColumns="False">
<AlternatingItemStyle
BackColor="GhostWhite"></AlternatingItemStyle> <ItemStyle
BackColor="Gainsboro"></ItemStyle>
<Columns>
<asp:HyperLinkColumn Target="_self"
DataNavigateUrlField="Form_Path_File_NM" DataTextField="Form_Number"
SortExpression="Form_Number" HeaderText="NUMBER">
<HeaderStyle Width="10%" CssClass="TableHeader"></HeaderStyle>
<ItemStyle CssClass="TableData"></ItemStyle>
</asp:HyperLinkColumn>
<asp:BoundColumn DataField="Form_Name" SortExpression="Form_Name"
HeaderText="NAME">
<HeaderStyle Width="50%" CssClass="TableHeader"></HeaderStyle>
<ItemStyle CssClass="TableData"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Description"
SortExpression="Description" HeaderText="CATEGORY">
<HeaderStyle Width="25%" CssClass="TableHeader"></HeaderStyle>
<ItemStyle CssClass="TableData"></ItemStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="Form_State_CD"
SortExpression="Form_State_CD" HeaderText="STATE">
<HeaderStyle Width="15%" CssClass="TableHeader"></HeaderStyle>
<ItemStyle CssClass="TableData"></ItemStyle>
</asp:BoundColumn>
</Columns>
</asp:datagrid>
*********************************************

TIA,

--
Joe

VBA Automation/VB 6/C++/C#/ VB.NET/Web and DB development


Nov 19 '05 #3
Jon
Before the line
dgForms.DataSource = dvForms
add
dvForms.Sort(OrderBy)

Jon

"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
Jon,

Sorry for the delay. I do create a dataview. Here's the code:

Private Sub PopulateClaimFormsDataGrid(ByVal OrderBy As String, ByVal
SortDirection As String)

'Retrieve Claim Froms data from database
Dim cForm As New ClaimForm
dtClaimForms = cForm.LoadClaimForms(hdnLineOfBusniessID.Value,
hdnSearchText.Value, hdnSelectedCategory.Value, OrderBy, SortDirection)

'If Claim Forms are found, display sorted data
If dtClaimForms.Rows.Count > 0 Then
Dim dvForms As New DataView
dvForms = dtClaimForms.DefaultView

lblFormMsg.Text = String.Empty
dgForms.DataSource = dvForms
dgForms.DataBind()
Else
lblFormMsg.Text = "Can't locate any forms for the provided
data."
ClearClaimsFormsDataGrid()
End If

cForm = Nothing
End Sub
This is not the problem. The SortCommand event is never called. So, this
function doesn't matter. The question is, why is the web server not
firing
the SortCommand event for the datagrid....

Thanks,

Joe
--
Joe

VBA Automation/VB/C++/Web and DB development
"Jon" wrote:
We need to see what you do in PopulateClaimFormsDataGrid

You would need to create a DataView and set it Sort property to the
e.SortExpression param you pass then bind the DataGrid to the DataView
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com...
> Hello,
>
> I have a datagrid in an nested html table (one table inside of another
> table) and have set the allowsSorting property to true. I've created
> in
> the
> code-behind a method (Sub - I'm using VB.NET) that handles the
> SortCommand
> event of the data grid. I've included the declaration of the Sub
> below.
> EnableViewState is set to false; we reload the DataSource each time the
> page
> posts.
>
> Would anyone know why this DataGrid doesn't sort? The web server isn't
> executing the SortCommand event handler.
>
> If tehre is any other information that I can offer, please elt me know.
> This really has me stumped.
>
> Sub Declaration:*********************************
> Private Sub SortDataGridColumns(ByVal sender As System.Object, ByVal e
> As
> System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
> dgForms.SortCommand
>
> PopulateClaimFormsDataGrid(e.SortExpression,
> SwapSortDirection(e.SortExpression))
> End Sub
> *********************************************
>
> Data Grid HTML**********************************
> <asp:datagrid id="dgForms" runat="server" CssClass="Interior"
> AllowSorting="True" AutoGenerateColumns="False">
> <AlternatingItemStyle
> BackColor="GhostWhite"></AlternatingItemStyle> <ItemStyle
> BackColor="Gainsboro"></ItemStyle>
> <Columns>
> <asp:HyperLinkColumn Target="_self"
> DataNavigateUrlField="Form_Path_File_NM" DataTextField="Form_Number"
> SortExpression="Form_Number" HeaderText="NUMBER">
> <HeaderStyle Width="10%" CssClass="TableHeader"></HeaderStyle>
> <ItemStyle CssClass="TableData"></ItemStyle>
> </asp:HyperLinkColumn>
> <asp:BoundColumn DataField="Form_Name" SortExpression="Form_Name"
> HeaderText="NAME">
> <HeaderStyle Width="50%" CssClass="TableHeader"></HeaderStyle>
> <ItemStyle CssClass="TableData"></ItemStyle>
> </asp:BoundColumn>
> <asp:BoundColumn DataField="Description"
> SortExpression="Description" HeaderText="CATEGORY">
> <HeaderStyle Width="25%" CssClass="TableHeader"></HeaderStyle>
> <ItemStyle CssClass="TableData"></ItemStyle>
> </asp:BoundColumn>
> <asp:BoundColumn DataField="Form_State_CD"
> SortExpression="Form_State_CD" HeaderText="STATE">
> <HeaderStyle Width="15%" CssClass="TableHeader"></HeaderStyle>
> <ItemStyle CssClass="TableData"></ItemStyle>
> </asp:BoundColumn>
> </Columns>
> </asp:datagrid>
> *********************************************
>
> TIA,
>
> --
> Joe
>
> VBA Automation/VB 6/C++/C#/ VB.NET/Web and DB development


Nov 19 '05 #4
Joe
Jon,

Thanks for your suggestion. This however doesn't solve the problem.

The issue is that the SortCommand Event handler isn't firing. The code
works. The initial sort if handled in the SQL built in another class. The
event handler isn't firing. Do you have any idea why?
--
Joe

VBA Automation/VB/C++/Web and DB development
"Jon" wrote:
Before the line
dgForms.DataSource = dvForms
add
dvForms.Sort(OrderBy)

Jon

"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
Jon,

Sorry for the delay. I do create a dataview. Here's the code:

Private Sub PopulateClaimFormsDataGrid(ByVal OrderBy As String, ByVal
SortDirection As String)

'Retrieve Claim Froms data from database
Dim cForm As New ClaimForm
dtClaimForms = cForm.LoadClaimForms(hdnLineOfBusniessID.Value,
hdnSearchText.Value, hdnSelectedCategory.Value, OrderBy, SortDirection)

'If Claim Forms are found, display sorted data
If dtClaimForms.Rows.Count > 0 Then
Dim dvForms As New DataView
dvForms = dtClaimForms.DefaultView

lblFormMsg.Text = String.Empty
dgForms.DataSource = dvForms
dgForms.DataBind()
Else
lblFormMsg.Text = "Can't locate any forms for the provided
data."
ClearClaimsFormsDataGrid()
End If

cForm = Nothing
End Sub
This is not the problem. The SortCommand event is never called. So, this
function doesn't matter. The question is, why is the web server not
firing
the SortCommand event for the datagrid....

Thanks,

Joe
--
Joe

VBA Automation/VB/C++/Web and DB development
"Jon" wrote:
We need to see what you do in PopulateClaimFormsDataGrid

You would need to create a DataView and set it Sort property to the
e.SortExpression param you pass then bind the DataGrid to the DataView
"Joe" <Jo*@discussions.microsoft.com> wrote in message
news:7F**********************************@microsof t.com...
> Hello,
>
> I have a datagrid in an nested html table (one table inside of another
> table) and have set the allowsSorting property to true. I've created
> in
> the
> code-behind a method (Sub - I'm using VB.NET) that handles the
> SortCommand
> event of the data grid. I've included the declaration of the Sub
> below.
> EnableViewState is set to false; we reload the DataSource each time the
> page
> posts.
>
> Would anyone know why this DataGrid doesn't sort? The web server isn't
> executing the SortCommand event handler.
>
> If tehre is any other information that I can offer, please elt me know.
> This really has me stumped.
>
> Sub Declaration:*********************************
> Private Sub SortDataGridColumns(ByVal sender As System.Object, ByVal e
> As
> System.Web.UI.WebControls.DataGridSortCommandEvent Args) Handles
> dgForms.SortCommand
>
> PopulateClaimFormsDataGrid(e.SortExpression,
> SwapSortDirection(e.SortExpression))
> End Sub
> *********************************************
>
> Data Grid HTML**********************************
> <asp:datagrid id="dgForms" runat="server" CssClass="Interior"
> AllowSorting="True" AutoGenerateColumns="False">
> <AlternatingItemStyle
> BackColor="GhostWhite"></AlternatingItemStyle> <ItemStyle
> BackColor="Gainsboro"></ItemStyle>
> <Columns>
> <asp:HyperLinkColumn Target="_self"
> DataNavigateUrlField="Form_Path_File_NM" DataTextField="Form_Number"
> SortExpression="Form_Number" HeaderText="NUMBER">
> <HeaderStyle Width="10%" CssClass="TableHeader"></HeaderStyle>
> <ItemStyle CssClass="TableData"></ItemStyle>
> </asp:HyperLinkColumn>
> <asp:BoundColumn DataField="Form_Name" SortExpression="Form_Name"
> HeaderText="NAME">
> <HeaderStyle Width="50%" CssClass="TableHeader"></HeaderStyle>
> <ItemStyle CssClass="TableData"></ItemStyle>
> </asp:BoundColumn>
> <asp:BoundColumn DataField="Description"
> SortExpression="Description" HeaderText="CATEGORY">
> <HeaderStyle Width="25%" CssClass="TableHeader"></HeaderStyle>
> <ItemStyle CssClass="TableData"></ItemStyle>
> </asp:BoundColumn>
> <asp:BoundColumn DataField="Form_State_CD"
> SortExpression="Form_State_CD" HeaderText="STATE">
> <HeaderStyle Width="15%" CssClass="TableHeader"></HeaderStyle>
> <ItemStyle CssClass="TableData"></ItemStyle>
> </asp:BoundColumn>
> </Columns>
> </asp:datagrid>
> *********************************************
>
> TIA,
>
> --
> Joe
>
> VBA Automation/VB 6/C++/C#/ VB.NET/Web and DB development


Nov 19 '05 #5

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

Similar topics

3
by: | last post by:
Is there an event that is invoked when a user sorts a column in a Windows Forms DataGrid? I have context senstive icons that are enabled\disabled depending upon the selected item in the...
5
by: Bill Todd | last post by:
In a WinForms application with a DataGrid bound to a DataTable, if I change the DefaultDataView.Sort property the order of the data in the grid does not change. If I change the Sort property...
4
by: Steve B. | last post by:
I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's reflect the contents of the grid cells. Sorting of columns (both thru VS and programmatically) work fine except, when the...
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...
5
by: Kurt Schroeder | last post by:
I'm using VS.net. I have created a component with the basic set of database commands. This component returns a record set that is bound to a datagrid. I want to add a dynamic sort, but am not sure...
1
by: troyblakely | last post by:
I am having trouble sorting a datagrid. I have read numerous posts on this and other lists, and tried most of the suggestions, but none of them have worked for me yet. I populate a dataset from two...
1
by: Jean-Claude Bertrand | last post by:
Hi! Windows of the application IO have to built (my first one in vb.Net) is made from 2 part: a) A grid wich will be used only to display the main information of the current record (so the...
2
by: shuckjunkmail | last post by:
It was suggested that I re-submit this question as a new post rather than adding onto an old and unanswered post. The basic problem has to do with the .NET datagrid and sorting. I am having...
4
by: G .Net | last post by:
Hi I have a question which I hope you can help with. I am setting the DataSource of a DataGrid to be a DataView. I am sorting the DataView by various fields which include a Date. When I...
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
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.