I work with .NET2003 C# windows form application, i add a datagrid in my form like this: -
dataGridProduct.DataSource = dataViewProduct;
-
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 : -
int currentRowIndex = dataGridProduct.CurrentRowIndex;
-
DataView dataViewProduct = (DataView)dataGridProduct.DataSource;
-
-
textBoxProductID.Text = dataViewProduct.Table.Row[currentRowIndex]["ProductID"].ToString();
-
textBoxProductName.Text = dataViewProduct.Table.Row[currentRowIndex]["ProductName"].ToString();
-
/* but when i click the columnHeader to get the data sorted, the dataViewProduct rowIndexes are still the same when it was assigned
-
(dataViewProduct = getAllProducts();), and i see only the dataViewProduct.Sort is changing. Can i have the dataViewProduct's data also sorted inside it?
-
*/
-
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
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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
|
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();
|
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
|
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.
| |
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...
|
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
|
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.
|
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...
|
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: 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...
| |
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,...
|
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...
|
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.
| |