2 Replies - 8077 Views - Last Post: 23 May 2006 - 08:51 AM Rate Topic: -----

#1 dhruba.bandopad  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 30-March 06

HELP: Edit a DataSet (not DataGrid)

Posted 23 May 2006 - 03:50 AM

I have a DataGrid which has checkbox columns. The data source is a run-time created data set that I store in a session so I can rebind it during postbacks. I don't have a database or xml file, etc.

I am wondering if it's possible to edit a dataset directly? So when I click on a checkbox it will change the value in the dataset and store it back into session?

If this is not possible how can I use arrays or vectors to temporary store my checkbox statuses? I guess it's not possible to have one DataGrid have more than one datasource...

Is This A Good Question/Topic? 0
  • +

Replies To: HELP: Edit a DataSet (not DataGrid)

#2 sontek  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 283
  • Joined: 13-September 01

Re: HELP: Edit a DataSet (not DataGrid)

Posted 23 May 2006 - 06:25 AM

Well you can do something like: dataSet1.Tables[0].Rows[4].ItemArray[0] = "NEW VALUE" but since you're clicking a checkbox in the datagrid it should be firing an event that you can handle and then just update the row it is in.

DataRow[] customerRow = 
	dataSet1.Tables["Customers"].Select("CustomerID = 'ALFKI'");

customerRow[0]["CompanyName"] = "Updated Company Name";
customerRow[0]["City"] = "Seattle";


This post has been edited by sontek: 23 May 2006 - 06:26 AM

Was This Post Helpful? 0
  • +
  • -

#3 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: HELP: Edit a DataSet (not DataGrid)

Posted 23 May 2006 - 08:51 AM

Yes you can edit the dataset directly, one way is as sontek has already shown.
Although I prefer to use names instead of numbers, it is easier to remember the column names rather than using numbers.

Me.DataSet1.Tables("Table name").Rows(0).Item("Column Name") = "New Value"


Since you have check boxes, you can use the CheckStateChanged procedure to handle the checkboxes as they are checked/unchecked. They are only boolean values, true = checked and false = not checked.

You could have something like this which will modify the selected row and column in the datagrid:
Me.DataSet1.Tables("Table name").Rows(Me.DataGrid1.CurrentRowIndex).Item(Me.DataGrid1.CurrentCell.ColumnNumber) = "New Value"



By using the CurrentRowIndex and the CurrentCell.ColumnNumber, it will modify whichever record in the dataset that you currently working with in your datagrid.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1