473,486 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

SortCommand in datagrid, dataview....

Trying to use the sortcommand in my datagrid, the subroutine
"Sort_Grid" error message is prompting: Name 'objDataView' is not
declared.
'''''''''
Sub bindSwGrid()
Dim strSQL As String = "SELECT * FROM cards"
Dim objConnection As New SQLConnection(strConnection)
Dim objAdapter As New SQLDataAdapter(strSQL,
objConnection)
Dim objDataSet As New DataSet()

objAdapter.Fill(objDataSet, "cards")

Dim objDataView As New
DataView(objDataSet.Tables("cards"))

swGrid.DataSource = objDataView
swGrid.DataBind()
End Sub

Sub Sort_Grid(sender As Object, e As DataGridSortCommandEventArgs)
objDataView.Sort = e.SortExpression

swGrid.DataBind()
End Sub
''''''''''
??
Ed

Jul 3 '07 #1
1 1248
You declared objDataView in bindSwGrid procedure - therefore it is only
visible inside that procedure (and not in Sort_Grid where you are referencing
it).
"27**@cox.net" wrote:
Trying to use the sortcommand in my datagrid, the subroutine
"Sort_Grid" error message is prompting: Name 'objDataView' is not
declared.
'''''''''
Sub bindSwGrid()
Dim strSQL As String = "SELECT * FROM cards"
Dim objConnection As New SQLConnection(strConnection)
Dim objAdapter As New SQLDataAdapter(strSQL,
objConnection)
Dim objDataSet As New DataSet()

objAdapter.Fill(objDataSet, "cards")

Dim objDataView As New
DataView(objDataSet.Tables("cards"))

swGrid.DataSource = objDataView
swGrid.DataBind()
End Sub

Sub Sort_Grid(sender As Object, e As DataGridSortCommandEventArgs)
objDataView.Sort = e.SortExpression

swGrid.DataBind()
End Sub
''''''''''
??
Ed

Jul 3 '07 #2

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

Similar topics

2
3266
by: Alpha | last post by:
I have a window application. In one of the form, a datagrid has a dataview as its datasource. Initial filtering result would give the datavew 3 items. When I double click on the datagrid to edit...
2
8479
by: Ken Tucker | last post by:
I've read about this issue in many articles across the net... But haven't found a solution. I see all kinds of custom code to perform sorting with datagrids, but my example is so simple, I must...
4
1985
by: Steven | last post by:
Hi there, I am having a weird problem. I have a datagrid with both an ItemCommand and a SortCommand. It was working fine until a day ago. Now, whenever I click a column to fire the...
0
938
by: lien | last post by:
In march 23, 04. Steven Cheng showed us how to do sortcommand for datagrid created at run time (thank you) . What if I have mixed static and dynamic columns? that is colunms added into static...
5
1424
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...
2
1334
by: Dexter | last post by:
Hello all, I have a problem with SortCommand event. When i click at a linkbutton with commandname property as "Sort", the postback is raised, but don't execute SortCommand. Somebody have any...
1
2038
by: Alex Maghen | last post by:
I have a DataGrid on my ASPX and I'm confused about the interaction with the page based on whether the page is just loading or is being reloaded with a call to the SortCommand of the DataGrid: ...
3
3751
by: Mark Gilkes | last post by:
Hi, I have an aspx page in which I am building a DataGrid control in the code-behind dynamically. The DataGrid is declared along with BoundColumns and bound to the datasource, then added to a...
2
3657
by: Joey | last post by:
I have an asp.net 1.1 C# web application with a datagrid. I set the datagrid's "AllowSorting" property to "True". Then I created a sort function for it by selecting the datagrid in the designer,...
0
7099
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6964
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6842
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7319
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.