Re: Can not sort datagrid

Tech-Archive recommends: Speed Up your PC by fixing your registry



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" <Joe@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:7F7B4470-D673-477B-8B6C-8E3921C799A3@xxxxxxxxxxxxxxxx
> > 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.DataGridSortCommandEventArgs) 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
>
>
>
.



Relevant Pages

  • Re: neue Zeile einer DataView hinzufügen
    ... Und wie heisst die DataTable, ... Sub TEST ... Dim NeueZeile As DataRowView =TestDataView.AddNew ... Eine DataView ist kein Datenspeicher, ...
    (microsoft.public.de.german.entwickler.dotnet.vb)
  • Re: Navigation per Buttons
    ... Private Sub Page_Load(ByVal sender As System.Object, ... End Sub ... Dim rownumber As Integer = CType, ... > Dim objDataView As DataView ...
    (microsoft.public.de.german.entwickler.dotnet.asp)
  • Re: error when adding column to datatable: There is no row at posi
    ... Private Sub cmdSetup_Click(ByVal sender As System.Object, ... Dim myDataColumn As DataColumn ... Dim dataview As New DataView ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: error when adding column to datatable: There is no row at posi
    ... Private Sub cmdSetup_Click(ByVal sender As System.Object, ... Dim myDataColumn As DataColumn ... Dim dataview As New DataView ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: how to do Binding with code
    ... from the DataView - OK, it's "messy", but it works. ... Public Class Service ... Public Sub New( ... ' Save the connection, so we can use it do updates - maybe ...
    (microsoft.public.dotnet.languages.vb)