Click here to Skip to main content
14,695,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone, today I have the next problem:

I'm doing a conection with a database, and I show the info with a DataGrid.

This control has other control for edit the info loaded, but the edition makes of by rows; I need to change this, for do the edition for columns.

arshad alam 22-Sep-12 8:51am
Kindly explain your question. its not clear
TANicox 22-Sep-12 9:06am
Into the GridView, you can put a CommandField, ok?

Well, With this CommandField you can edit the table by rows.
I need to make the table editable by columns.

| xxxx | xxxx | Edit |< This edit the selected row

| Edit | Edit |< I need edit the entire column
| xxxx | xxxx |

1 solution

If you mean something along the lines of:
UPDATE db SET col1 = 'someVal'

I would add a row of TextBoxes above or below the DataGrid and when the user hits enter or clicks a button read all of the TextBox values, validate them, and then write a dynamic SQL query to manually update the data. After that reload the DataGrid to show the changes.
This way you can do any kind of validation, and you are in complete control of what can and can not be updated.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900