473,796 Members | 2,676 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,
objConnection)

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 " &
lblSorteer.Text
'Dim sSQl2 As String = "Select VoetballerNaam,
VoetballerPosit ie from Voetballers where ClubID = 1 order by
VoetballerNaam"

Dim objDataAdapter As New OleDbDataAdapte r(sSQl2,
objConnection)

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 =
"Keeper"
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 =
"Aanvaller"
Case 5
dgVoetballers.I tems(iRecords). Cells(1).Text =
"Coach"
End Select
Next

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">
<HTML>
<HEAD>
<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">
</HEAD>
<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">
<Columns>
<asp:ButtonColu mn DataTextField=" ClubNaam">
<HeaderStyle Wrap="False"></HeaderStyle>
</asp:ButtonColum n>
</Columns>
</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>
</body>
</HTML>
Nov 18 '05 #1
0 1298

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

Similar topics

2
945
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
1
2061
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?
7
4233
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.
2
2355
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
5
12239
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...
2
8498
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...
4
2353
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
2
1615
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 {
4
2117
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
0
9525
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,...
0
10452
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10221
jinu1996
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...
1
10169
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9050
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
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...
0
6785
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4115
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
2
3730
muto222
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.