Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Sorting

Sorting

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netalgorithmsbusiness
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Khan Bangash
    wrote on last edited by
    #1

    Hi All I m using asp.net with vb.net. There s a DataGrid Control on my page, There is a column Customer Name who's Text is set as below. in aspx page Look at its Text property how it is set. And the code of setcustomername sub is as follow. Function setcustomername(ByVal orderid As Integer) As String SelectQuery = "SELECT customers.customer_id,customers.customer_type, customers.fname, customers.lname FROM customers INNER JOIN cust_order ON customers.customer_id=cust_order.customer_id WHERE cust_order.order_id=" & orderid & "" selectcommand = New OleDbCommand(SelectQuery, Conn) total = selectcommand.ExecuteReader() While total.Read() If Not total.IsDBNull(0) Then cuid = total.getvalue(0) End If If Not total.IsDBNull(1) Then cusType = total.getvalue(1) End If If Not total.IsDBNull(2) Then first = total.getvalue(2) End If If Not total.IsDBNull(3) Then last = total.getvalue(3) End If End While If cusType = 1 Then camp_name = "" SelectQuery = "SELECT comp_name FROM biz_cust_extra WHERE customer_id=" & cuid & ";" selectcommand = New OleDbCommand(SelectQuery, Conn) total = selectcommand.ExecuteReader() While total.Read() If Not total.IsDBNull(0) Then camp_name = total.getvalue(0) Else camp_name = "" End If End While Return camp_name Else Return first & " " & last End If End Function U can see that if customer is business customer then its company name will b displayed, if it is end user then its name will b displayed. Now the column will have either name or company name. I want to Sort this column when some one click on its header. Can any one tell me how to do that. Its realy very urgent. Pls Help me. thanks in Advance.

    C 1 Reply Last reply
    0
    • K Khan Bangash

      Hi All I m using asp.net with vb.net. There s a DataGrid Control on my page, There is a column Customer Name who's Text is set as below. in aspx page Look at its Text property how it is set. And the code of setcustomername sub is as follow. Function setcustomername(ByVal orderid As Integer) As String SelectQuery = "SELECT customers.customer_id,customers.customer_type, customers.fname, customers.lname FROM customers INNER JOIN cust_order ON customers.customer_id=cust_order.customer_id WHERE cust_order.order_id=" & orderid & "" selectcommand = New OleDbCommand(SelectQuery, Conn) total = selectcommand.ExecuteReader() While total.Read() If Not total.IsDBNull(0) Then cuid = total.getvalue(0) End If If Not total.IsDBNull(1) Then cusType = total.getvalue(1) End If If Not total.IsDBNull(2) Then first = total.getvalue(2) End If If Not total.IsDBNull(3) Then last = total.getvalue(3) End If End While If cusType = 1 Then camp_name = "" SelectQuery = "SELECT comp_name FROM biz_cust_extra WHERE customer_id=" & cuid & ";" selectcommand = New OleDbCommand(SelectQuery, Conn) total = selectcommand.ExecuteReader() While total.Read() If Not total.IsDBNull(0) Then camp_name = total.getvalue(0) Else camp_name = "" End If End While Return camp_name Else Return first & " " & last End If End Function U can see that if customer is business customer then its company name will b displayed, if it is end user then its name will b displayed. Now the column will have either name or company name. I want to Sort this column when some one click on its header. Can any one tell me how to do that. Its realy very urgent. Pls Help me. thanks in Advance.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      The gridview has built in support for sorting. Otherwise, you need to render headers that are clickable, and that change the SQL that's executed, so it sorts by the correct fields.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups