473,699 Members | 2,417 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrid. How to keep the right keyfield value when Sort the DataGrid?

Hi everybody!

Got the logical error (wrong row (SSN) selected on
SelectedIndexCh ange event) when made a sort by non-key field in
Datagrid.

Used this Sub to keep the keyfield ("SSN"):

Private Sub dgrMain_Selecte dIndexChanged(B yVal sender As
System.Object,B yVal e As System.EventArg s) Handles
dgrMain.Selecte dIndexChanged
Session("SSN") =
dgrMain.Items(d grMain.Selected Index).Cells(1) .Text
Response.Redire ct("Default.asp x")
End Sub

Did sorting in a standart way. Everything works fine when the Grid is
sorted by SSN (what is cells(1)). But when you sort by any other field
it still choose the row like sorted by SSN.
Thanks for the help.
Eugene
Nov 18 '05 #1
0 1272

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

Similar topics

2
1821
by: mharness | last post by:
Hello, I'm new at this. Thanks for your help. I have form which displays a customer record and a datagrid of that customer's orders. I want to read the value of the OrderID (which is the keyfield), write it to a session variable, redirect to another form where I read the session variable and display the order detail. How do I read the OrderID value when the user clicks on a select button in a
1
1875
by: Stephen | last post by:
Was wondering if it is possible to take the contents of a row in a datagrid and use an event to copy over the details of the selected row into another datagrid. I'd like to be able to do the following: - I have a datagrid on my page which comes back as follows. The addresses are in a column which is databound. I would like to create an event on the on-click of the select link (located in the datagrid). On this event I would like to...
1
3021
by: mario | last post by:
I using datagrid and windows form in C# Question 1: I have selected a specified row and if I resize the form with the datagrid in it , I cannopt see anymore the row i have seleted until i scroll to it. I want to do this... the selected row must be all the time stay visible. How can I do That ???? Question 2:
2
9921
by: Chris Plowman | last post by:
Hi all, I was wondering if anyone can help me with a really annoying problem I have been having. I made a derived datagrid class that will select the row when a user clicks anywhere on a cell (multi-select without modifier keys). I got that working fine, but I also wanted to keep rows selected after a sort, which I do by storing the row's id in an arraylist. The idea was to do the sort and then go back and re-select the rows with that...
1
9496
by: xrow | last post by:
Hello I have a simple webservice / c# application that receives data from server and prints the data in the asp:datagrid control I have problem when sorting data in datagrid I have created SortCommand event in my .aspx file for my datagrid DataGrid2 but I am not able to access my datarecord nor dataset from my SortCommand event. I recieve also an error when running with created event if don't change event method declaration to public void...
1
2689
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting, paginantion or accepting the add and remove item events. What i am observing is that none of the vents are happening... (Sort, page, or item). I am sure I am missing something basic here... Need help... Thanks much
3
4216
by: Gene Hubert | last post by:
I'm using DataTable.ImportRow to move data from one datatable to another... Dim dt, dtTarget As DataTable Dim dr As DataRow dt = DirectCast(Me.DataSource, DataTable) dtTarget = dt.Clone 'copy the data structure dtTarget.DefaultView.Sort = String.Empty 'remove the sort
9
3371
by: John Hernry | last post by:
I have been watching the dotnet newsgroups for a couple of weeks now and scouring the net looking for a solution to my datagrid find functionality. With no luck. I am hoping that you can help me. I am an old VB6 coder used to using Sheridan controls, and I am just starting to learn the .net world. I am upgrading my music catalogue database, where the data is stored in an Access mdb file.
4
2715
by: skOOb33 | last post by:
I successfully autosized the columns and rows on my Datagrid, and am now facing another issue. Having the sorting ability by clicking the column headers is key, but when I do that, it resizes all my rows back to their defaults. I populate the datagrid, resize it accordingly and it works fine...just when I click the headers is when it messes up. It would be fine if I could run my autosizing again after the sorting is done since there...
0
8685
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, 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...
1
8908
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
8880
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 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...
0
7745
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...
0
4374
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...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
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
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.