473,724 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datagrid sorting does something wierd

I am trying to sort my second datagrid. And it works but only after i
click 2 times on the column header. The first time i click on the
header the data in the right order will add to the rows in the
datagrid. The second time i click on the header the top halve changes
in the right order too.

What i do wrong?

btw if i remove PlaatsVoetballe rs in the sub sorteergrid the first
click it does nothing the second time it sorts (no adding new rows)
Sorry for all the dutch in the code
my code

Private objDataset As DataSet = New System.Data.Dat aSet()
Private sConnectionStri ng As String =
"Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" &
Server.MapPath( "\WebApplicatio n1\data\TestMeg aDB.mdb") & ";"
Protected WithEvents dgClubs As System.Web.UI.W ebControls.Data Grid
Protected WithEvents dgVoetballers As
System.Web.UI.W ebControls.Data Grid
Private objConnection As OleDbConnection = New
OleDbConnection (sConnectionStr ing)
Protected WithEvents lblSorteer As System.Web.UI.W ebControls.Labe l
Protected WithEvents lblCount As System.Web.UI.W ebControls.Labe l
Protected WithEvents Label1 As System.Web.UI.W ebControls.Labe l

Dim test As Integer

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here

If Not Page.IsPostBack Then
lblSorteer.Text = "VoetballerNaam "

objConnection.O pen()
Dim sSQl As String = "Select * from Clubs where ClubNaam
<> 'Geen voetballer' order by ClubNaam"
Dim ObjCommand As OleDbCommand = New OleDbCommand(sS Ql,

Dim objDatareader As OleDbDataReader
objDatareader =
ObjCommand.Exec uteReader(Comma ndBehavior.Clos eConnection)

dgClubs.DataSou rce = objDatareader
dgClubs.DataBin d()
objDatareader.C lose()
End If
PlaatsVoetballe rs()
End Sub

Private Sub PlaatsVoetballe rs()
Dim sSQl2 As String = "Select VoetballerNaam,
VoetballerPosit ie from Voetballers where ClubID = 1 order by " &
'Dim sSQl2 As String = "Select VoetballerNaam,
VoetballerPosit ie from Voetballers where ClubID = 1 order by

Dim objDataAdapter As New OleDbDataAdapte r(sSQl2,

lblCount.Text = sSQl2
objDataAdapter. Fill(objDataset , "Voetballer s")

dgVoetballers.D ataSource = objDataset
dgVoetballers.D ataMember = "Voetballer s"
dgVoetballers.D ataBind()
VerwerkVoetball ersInGrid()

End Sub

Private Sub VerwerkVoetball ersInGrid()
Dim iRecords As Integer
For iRecords = 0 To dgVoetballers.I tems.Count - 1
Select Case dgVoetballers.I tems(iRecords). Cells(1).Text
Case 1
dgVoetballers.I tems(iRecords). Cells(1).Text =
Case 2
dgVoetballers.I tems(iRecords). Cells(1).Text =
"Verdediger "
Case 3
dgVoetballers.I tems(iRecords). Cells(1).Text =
"Middenveld er"
Case 4
dgVoetballers.I tems(iRecords). Cells(1).Text =
Case 5
dgVoetballers.I tems(iRecords). Cells(1).Text =
End Select

End Sub

Sub clubclicked(ByV al sender As Object, ByVal e As
DataGridCommand EventArgs)
Dim buttontest As TableCell = e.Item.Cells(1)
Dim buttonstring As String = buttontest.Text

End Sub

Sub VerwijderCollum s(ByVal s As Object, ByVal e As
DataGridItemEve ntArgs)
e.Item.Cells(1) .Visible = False
e.Item.Cells(2) .Visible = False

End Sub

Sub SorteerGrid(ByV al sender As Object, ByVal e As
DataGridSortCom mandEventArgs)
lblSorteer.Text = e.SortExpressio n.ToString()
PlaatsVoetballe rs()

End Sub

<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="Spe lerOverzicht.as px.vb"
Inherits="WebAp plication1.WebF orm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<title>WebForm1 </title>
<meta content="Micros oft Visual Studio.NET 7.0" name="GENERATOR ">
<meta content="Visual Basic 7.0" name="CODE_LANG UAGE">
<meta content="JavaSc ript" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
<body bgColor="#fffff f" MS_POSITIONING= "GridLayout ">
<form id="Form1" method="post" runat="server">
<asp:datagrid id="dgClubs" style="Z-INDEX: 101; LEFT: 6px;
POSITION: absolute; TOP: 2px" runat="server" Height="116px"
Width="188px" BackColor="Lime Green" BorderColor="Bl ack"
BorderStyle="So lid" ShowHeader="Fal se" OnItemCommand=" clubclicked"
OnItemDataBound ="VerwijderColl ums" Font-Bold="True"
Font-Names="Century Gothic">
<asp:ButtonColu mn DataTextField=" ClubNaam">
<HeaderStyle Wrap="False"></HeaderStyle>
</asp:ButtonColum n>
</asp:datagrid><a sp:label id="lblSorteer " style="Z-INDEX: 102;
LEFT: 24px; POSITION: absolute; TOP: 163px" runat="server"
Height="6px" Width="76px">17 </asp:label><asp: datagrid
id="dgVoetballe rs" style="Z-INDEX: 103; LEFT: 205px; POSITION:
absolute; TOP: -3px" runat="server" Height="392px" Width="272px"
AllowSorting="T rue" OnSortCommand=" SorteerGrid"></asp:datagrid><a sp:label
id="lblCount" style="Z-INDEX: 104; LEFT: 506px; POSITION: absolute;
TOP: 63px" runat="server" Height="13px" Width="361px">0 </asp:label>
<asp:Label id="Label1" style="Z-INDEX: 105; LEFT: 524px; POSITION:
absolute; TOP: 123px" runat="server" Height="24px"
Width="58px">La bel</asp:Label></form>
Nov 18 '05 #1
0 1293

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

Similar topics

by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child datagrid. HTML Datagrid1 TemplateColumn Table Header information Detail Information
by: Sargas Atum | last post by:
Hi all, 1. I have a problem with cell selection in a table in a DataGrid. I dont want that anybody writes in the cells. That was not a problem I changed them to "read only", but if I am going to scroll the table up and down or from right to the left the content of the active cell will be selected as if for copy/paste. How can I deactivate such a behaviour?
by: Pete Davis | last post by:
A different question this time. I have a DataGrid bound to a collection. Is there any way for me to allow sorting? The DataGrid.AllowSorting=true doesn't work, but that's probably because it can't assume the data types and thus can't sort them. I thought about implementing IComparable, but I don't see how that would work since it doesn't apply generically to all the fields/properties of the class. Thanks.
by: Raj | last post by:
Hi, When we are sorting the DataGrid Boolean column the grid is becoming redcross. I have my own PPMIPDataGridBoolColumn class inherited from System.Windows.Forms.DataGridBoolColumn. In this inherited class I have one DataGridValueChangedEventHandler event handler. I am overriding Edit() to know the current state of the cell. I am overriding Paint() to know the if the user has been editing the cell. I am also overriding the Commit() to
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. The ID is a member of the keys array. I then create a DataView dv over the table, and sort it by Display and ID column (in case of duplicate Display). I then set my DataGrid.DataSource = dv; I then load the datatable with my rows, and this is...
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 just be missing something. Basically, I have a .aspx page that is very simple and has a simple datagrid. All code is in the .cs page for the datagrid (hence, I'm doing all datagrid work programmatically). The datagrid is populated from a SQL table...
by: Mark Travis | last post by:
Hi all, I have written a simple Web Application that displays a query result onto a page using the ASP DataGrid. To Digress ======= Development information about the page is as follows 1. The database used is SqlServer 2000. 2. A Stored Procedure is dragged onto the page from the Server Explorer
by: ddaniel | last post by:
I have read many posts and seen many papers on the different techniques for sort and filtering datagrids. Many do re-queries against the dB ala Fritz Onion. I am trying to leverage the Dataview. The following control simply responds to a sort request and/or a pageing reqeust with an empty table (header only). Any ideas ? Code behind : namespace OakTree.data {
by: Manny Chohan | last post by:
hi guys, my code is returning an array and i need to create datagrid so that i can have sorting and implement prev....next function on it to navigate. is there any way this can be done in codebehind file. I am using c#. Thanks Manny
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.