Sorting Gridview templatefield (VWD Express)

Last post 05-10-2008 8:13 AM by Rehabman. 4 replies.

Sort Posts:

  • Sorting Gridview templatefield (VWD Express)

    05-08-2008, 2:46 PM
    • Loading...
    • Rehabman
    • Joined on 02-15-2008, 6:11 PM
    • Posts 8

    I have 2 questions, which have presented me with about 2 days of lost work, trying to figure this out. 

    1.  I have 2 gridviews.  Once a record is "Selected" in the top gridview1 then the gridvew2 is populated based on a Select Query.

     This works fine.  Each row of both gridviews allow sorting at the column header, execpt the one row in the gridview2 which is a templatefield . I need to sort by this field, but I cannot get it to work. Any and all help would be appreciated.

     

    2. Next,  I would like to write a select statement that retrieves all records with a date of 24 months back. I can get it to work in vb express datagrid using DATEADD('M', -24, Now), but I cannot get it to work in ASP using vwd express

     Please help!
     

     

       

     

  • Re: Sorting Gridview templatefield (VWD Express)

    05-08-2008, 3:50 PM
    • Loading...
    • KLilley
    • Joined on 12-04-2007, 8:57 PM
    • Posts 51

     Could you post the code for your gridview, and the code involving the select statement as well?

  • Re: Sorting Gridview templatefield (VWD Express)

    05-09-2008, 7:55 AM
    • Loading...
    • Rehabman
    • Joined on 02-15-2008, 6:11 PM
    • Posts 8

    My  Select statement calls all the fields      -    Select *

    Then I use the Row DataBound Sub to modifiy the data in one of the fields.  This iworks.

    Then when trying to use sort or use filterexpression on that field, or sorting neither seem to work.

     *************************************

    Here is what I think is happening.

    The original query retrieves all rows including the field I want to change called "Dist" which is "0" in every record.

    Although the gridview shows the properly calculated new number in the "Dist" field, I think the sort routine must only look at the query value of distance which was "0" instead of the gridview value which is populated through the RowDataBound Sub

    If this is true then the solution would be to do the distance calcuation within the SELECT statement using an AS statement.  This seems to work but I cannot figure out how to put the 10 lines of calculations in the SELECT statement.. I tried using a VB Protected Function, but can't get it to work in the SELECT Statement either

    AM I on the right track?

    ANy Suggestions would be helpful

    Thanks

     

     

  • Re: Sorting Gridview templatefield (VWD Express)

    05-09-2008, 9:33 AM
    -----------
    :) MAdHU
    -----------
  • Re: Sorting Gridview templatefield (VWD Express)

    05-10-2008, 8:13 AM
    • Loading...
    • Rehabman
    • Joined on 02-15-2008, 6:11 PM
    • Posts 8

     It seems the sorting in gridview uses the datasource, not the gridview data to sort. I do not see a way to sort the actual gridview data.


     

Page 1 of 1 (5 items)