473,795 Members | 2,826 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

get the right dataview record

7 New Member
I work with .NET2003 C# windows form application, i add a datagrid in my form like this:

Expand|Select|Wrap|Line Numbers
  1. dataGridProduct.DataSource = dataViewProduct;
  2.  
I also make the allowSort property of the datagrid set to be true. Here is my problem, i want to make when i click one of the datagrid cell, said there're ProductID or ProductName, i also show it in my textBoxProductI D or textBoxProductN ame. If i don't have sorting, and i click in the datagrid cell, i can show it by using its MouseUp or MouseDown event. But when i use sorting, which means its columnHeader can be clicked by the user, i get the wrong data of dataView. As my opinion, only the dataView.Sort property is changing, but not the order of dataView's data. How can i view the right data of the cell in the datagrid.

These are my codes inside MouseDown event :
Expand|Select|Wrap|Line Numbers
  1. int currentRowIndex = dataGridProduct.CurrentRowIndex;
  2. DataView dataViewProduct = (DataView)dataGridProduct.DataSource;
  3.  
  4. textBoxProductID.Text = dataViewProduct.Table.Row[currentRowIndex]["ProductID"].ToString();
  5. textBoxProductName.Text = dataViewProduct.Table.Row[currentRowIndex]["ProductName"].ToString();
  6. /* but when i click the columnHeader to get the data sorted, the dataViewProduct rowIndexes are still the same when it was assigned 
  7. (dataViewProduct = getAllProducts();), and i see only the dataViewProduct.Sort is changing. Can i have the dataViewProduct's data also sorted inside it?
  8. */
  9.  
that's all, it's quite long, but i will wait for your reply. Thank you before.
Apr 16 '07
10 4296
Plater
7,872 Recognized Expert Expert
If the object is databound, you must add/remove entries from the source (a datatable or dataset ?). DataTable's have like a "CreateRow( )" or something like that
Jun 11 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2575
by: Johann Blake | last post by:
I'm not sure that I entirely understand the purpose of the AcceptChanges methon in a DataView. I added a new record to a DataView and noticed that its RowState indicated it as being "Added". If I execute the Update method on an adapter for the table that the DataView is based on, the new record will indeed be written to the database. But if I call AcceptChanges prior to executing the Update method, the RowState for the new record is...
0
984
by: TdarTdar | last post by:
Hello, I was wondering if there is a way to used a dataview like the following and how to do it. I have a new table, no records. I have a new asp.net 2.0 beta 2 webform, with a sqldatasource of that table with the insert update delete option selected. I then put a dataview and attached it to that sqldatasource
8
3900
by: Dave Hagerich | last post by:
I'm using a DataGrid with a DataSet and I'm trying to filter the data being displayed, using the following code as a test: DataView theView = new DataView(theDataSet.Tables); theView.RowFilter = "'Record ID' = '0'"; theView.RowStateFilter = DataViewRowState.ModifiedCurrent; Debug.WriteLine(string.Format("RowFilter = {0}", theView.RowFilter)); RecordDataGrid.DataSource = theView; RecordDataGrid.DataBind();
1
2107
by: Jay Zweedyk | last post by:
Ok I want to filter a dataset into a dataview and be able to reference back to the dataset from the filtered dataview. Example: 100 record dataset filter it to a 5 record dataview loop thought the Dataview and update the original dataset .... if there is a way to index the dataset from the dataview. I know I can update the
6
444
by: Dazz | last post by:
Hi I desperately need some help. I want to have a DataView sorted alphabetically by a specific column, then I want to find the first record that begins with the letter the user inputs and get that record number. I don't however want a filter as the user must still be able to scroll up and down the DataView. Thanks. Any help would be greatly appreciated.
13
2116
by: Steve | last post by:
I have a form with a dataset and a datagrid. I created a dataview on this dataset. When the user modifies the datagrid, I look up this record in the dataview to make sure it is unique. Here is the confusion......... I thought that the DataView is the view from the dataset, but it seems that the dataview has the records that are in the datagrid, because everytime I search for a record that I know is NOT in the dataset, it finds it. I...
7
10212
by: randy1200 | last post by:
I have an orders table. Each record in the orders table contains a customer id. I have a customer table. The primary key of each record in the customer table is the customer id. After getting a subset from the orders table, I need to take the customer ids in the orders table subset, and list each record in the customer table that has a matching customer id. If I were in t-sql, this would be an easy inner join. In this case, I get
2
10014
by: HansP | last post by:
Hi, I am really in a deadlock with this problem. In my VS2005 C# handheld application, I have a grid with Workorders. Another grid (child) are the ACTIONS, performed for each workorder. Both grids have Dataviews as DataSource. The child grid, filtered with RowFilter in the DataView works fine.
1
3204
by: glbdev | last post by:
I searched around but cannot find an answer to this problem, if there is an answer. I have a DataView and a dropdownlist both on the same page. The dropdown list is a bound list of companies. The DataView shows the company details and you can delete a record, if necessary. If you change the selection on the dropdown list, the DataView is refreshed. This works fine. The problem I am having is that if I delete the record on the...
0
9672
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...
0
10438
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...
1
10164
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
9042
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
7540
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
5437
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
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
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
3727
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.