473,889 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Programically update a colum in a datagrid

Jim
I have a datagrid with a DataAdapter as the DataSource. The user fills in
their data for 3 columns and I want to programically add a value to the 4th
(invisible) column (employee number). That way when the user saves the data I
can use the data already in the datagrid.

Typically the user will add several rows before the DataSet.HasChan ges is
called and the DataAdapter.Upd ate(AllChanges) is called. I want to add an
employee number to each record programmically within this save routine. Yeah,
stupid, but I need the answer to complet this project.

I really don't want to use a DataReader and write the SQL UPDATE or INSERT
commands, this needs to be done for about 30 tables and I don't have the time.
--
Thanks, Jim
Nov 21 '05 #1
3 1821
Jim,
I have a datagrid with a DataAdapter as the DataSource. The user fills in
their data for 3 columns and I want to programically add a value to the
4th
(invisible) column (employee number). That way when the user saves the
data I
can use the data already in the datagrid.

Typically the user will add several rows before the DataSet.HasChan ges is
called and the DataAdapter.Upd ate(AllChanges) is called. I want to add an
employee number to each record programmically within this save routine.
Yeah,
stupid, but I need the answer to complet this project.

I really don't want to use a DataReader and write the SQL UPDATE or INSERT
commands, this needs to be done for about 30 tables and I don't have the
time.
--


And why can you not make this?

(Especially the text acceptchanges is interesting by the way, normally you
don't need that with a dataadapter, so show some code around that)

I hope this helps,

Cor
Nov 21 '05 #2
Jim
Huh?

I have a dataset with a row that has been updated or inserted by the user
via a datagrid. I need to insert a value in one of the grids columns for each
row prior to saving the data. I am using ds.HasChanges to validate that
changes have occured and da.Update(Chang es) to update the records. Below is
the update code:

Dim AllChanges As DataSet

If dsAnesthesia.Ha sChanges() = True Then
AllChanges = dsAnesthesia.Ge tChanges()
daAnesthesia.Up date(AllChanges )
End If

All I want to do is programically insert a value into a bound datagrid
column prior to saving the row. How do I programically access a specific
column whenever the user is either adding or updating a record using a
datagrid.
--
Thanks, Jim
"Cor Ligthert [MVP]" wrote:
Jim,
I have a datagrid with a DataAdapter as the DataSource. The user fills in
their data for 3 columns and I want to programically add a value to the
4th
(invisible) column (employee number). That way when the user saves the
data I
can use the data already in the datagrid.

Typically the user will add several rows before the DataSet.HasChan ges is
called and the DataAdapter.Upd ate(AllChanges) is called. I want to add an
employee number to each record programmically within this save routine.
Yeah,
stupid, but I need the answer to complet this project.

I really don't want to use a DataReader and write the SQL UPDATE or INSERT
commands, this needs to be done for about 30 tables and I don't have the
time.
--


And why can you not make this?

(Especially the text acceptchanges is interesting by the way, normally you
don't need that with a dataadapter, so show some code around that)

I hope this helps,

Cor

Nov 21 '05 #3
Jim,

Sorry, I misreaded haschanges for acceptchanges.

However why not just before you update loop through the datatable.

If dsAnesthesia.Ha sChanges() = True Then
AllChanges = dsAnesthesia.Ge tChanges() for each dr in AllChanges.Tabl es(0).rows
'assuming it is one table
dr.item(3) = "whatever"
next daAnesthesia.Up date(AllChanges ) dsAnestesia.acc eptchanges
'with getchanges you get a copy therefore the update changes will not be
done by the dataadapter End If


To hide the column in a simple way you can use this sample.

http://www.windowsformsdatagridhelp....3-a3539697edbd

I hope this helps,

Cor
Nov 21 '05 #4

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

Similar topics

5
1955
by: Sadun Sevingen | last post by:
hi i get dataset from'an webservice so i don't have an adaptor... dataset's structure is same as mine database table.... how can i update database table according to dataset...
0
1199
by: Ash | last post by:
Hi, I'm using Vb.NET webform, connecting to sql server database on the local machine. I used datagrid propery builder to add the edit, update and cancel colum. On the code, i have: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SqlDataAdapter1.Fill(DataSet11) DataGrid1.DataBind()
2
5679
by: Manish | last post by:
Hey folks I am having a weird problem in ASP .Net. My page is in C#. I have a datagrid, which populates based on selection in drop down box on ASP page. This datagrid has template textbox colum in itemtemplate. Datagrid is something like this- Category Week Amt Week% Button Revenue 1 100 Update Revenue 2 200 Update Cost 1 25 25
11
1724
by: Fred Nelson | last post by:
I have an application in which it would be VERY beneficial if I could obtain the names of the colums in a datagrid. For example dim datagrid1 as new datagrid datagrid1.datasource = (stored procedure that loads datagrid) datagrid1.databind() I am able to obtain the data in the datagrid by its relative number however
2
5045
by: Agnes | last post by:
In myDatagrid, there is 3 columns, account code, debit,credit. If the user input some particular a account code in column1 , i need to based on the contect of column1, to disable column2(debit),column3(credit) I try processcmdkey , onKeypress, onKeydown event already ( set e.handled = false , just like textbox event) However, it still let the user input anyfield ( after use press'tab', the field will gone blank) My aim is, user press any...
3
1362
by: Bill Nguyen | last post by:
I found that rows in datagrid can be sorted by clicking on the column header. However, this doesn't refresh the .currentindex DataGrid1.CurrentCell.RowNumber I need either to disable colum sorting programmatcially or somehow refresh the DataGrid1.CurrentCell.RowNumber index so that it will reflect the correct rownumber.
0
1051
by: Jet Mah | last post by:
Hi, Mert I want to update the "read_status" colum when reading data, this is my way as below: // ----------------------------------------------------------------------------------------------------- string strConn = "server=" + server + ";database=" + database + ";uid=" + uid + ";pwd=" + pwd; SqlConnection sqlConn = null;
5
2599
by: superjacent | last post by:
Hope someone can help. I have a saved parent form containing an unbound sub-form. I set the SourceObject (form) after the Parent Form opens/loads. The sub-form (datasheet view) basically displays the results of a cross-tab query The cross-tab query is created dynamically (in code) as the column headings are subject to change. I therefore have to create a new form (in code) and add the necessary
3
33771
by: Manikandan | last post by:
Hi, I have table with three columns as below table name:exp No(int) name(char) refno(int) I have data as below No name refno 1 a 2 b 3 c
0
9961
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
9802
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
10780
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
10887
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
9597
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
7991
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
6015
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4248
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3252
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.