Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 1.x and 2.0 Application Design Application design with ASP.NET 1.0, 1.1, and 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.x and 2.0 Application Design section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 28th, 2005, 12:55 PM
Registered User
 
Join Date: Sep 2005
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Datagrid sorting

Hi Guys,

I am struggling with sorting the datagrid along with paging...

here is my code. Everything works fine expect the sorting thing...i am not sure how to get hold of user entered values...am i not sure if i calling the sort function correctly...

Code:
<script language="VB" runat="server">
Protected strSQL AS String

Sub SubmitBtn_Click(Sender As Object, E As EventArgs)
CodeSearchList.CurrentPageIndex = 0
BindData()
End Sub

Sub BindData()
Dim DS As DataSet
Dim SqlConn As SqlConnection
Dim Sqlda as SqlDataAdapter
Dim strConnection As String
Try

strConnection=ConfigurationSettings.AppSettings("conString")
SqlConn = New SqlConnection(strConnection)
strSQL= "Select * from SubConsultant where ((CODE LIKE '%" +Codetxtbox.text+ "%') OR Description LIKE '%" +Codetxtbox.text+ "%'))"

Sqlda = New SqlDataAdapter(strSQL, SqlConn)

DS = new DataSet()
Sqlda.Fill(DS,"LookupCodes")
If DS.Tables(0).Rows.Count > 0 Then
CodeSearchList.DataSource = DS.Tables("LookupCodes")
CodeSearchList.DataBind()
CodeSearchList.Visible = True
else
Response.Write ("No Records Found")
CodeSearchList.Visible = False
end if
Catch ex AS Exception

Response.Write(ex.ToString & "<br>")
Finally
SqlConn.Close()
End Try
End Sub

Sub CodeSearchList_Paging(sender As Object, e As DataGridPageChangedEventArgs)
CodeSearchList.CurrentPageIndex = e.NewPageIndex
BindData()
End Sub

Sub SortCommand_OnClick(Source As Object, E As DataGridSortCommandEventArgs)
strSQL = strSQL & " ORDER BY " & E.SortExpression
BindData()
End Sub

</script>
Thanks in advance...

  #2 (permalink)  
Old September 30th, 2005, 11:44 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

In your sortcommand sub, you need to refill your dataset, if that is what you are using for your datasource then rebind your grid. Everthing else looks ok.

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorting a datagrid trekmp ADO.NET 7 December 18th, 2004 06:56 AM
Datagrid sorting by non alphabetical sorting? LLAndy VS.NET 2002/2003 1 July 15th, 2004 01:20 AM
DataGrid Sorting spm74 ASP.NET 1.0 and 1.1 Basics 3 May 26th, 2004 08:52 AM
Sorting a Datagrid - Help Please! Pauline VS.NET 2002/2003 0 August 29th, 2003 06:20 AM
DataGrid Sorting Example SPRIBob BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 10 July 30th, 2003 09:48 AM



All times are GMT -4. The time now is 07:30 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.