Non editable row in GridView - c#

I am creating a web page using C# ASP.NET and Visual Studio 2008. I would like to create a dataentry form on my web page using GridView. Whenever a user may, he/she can edit the record on GridView (I have did this using edit, update, cancel option) but I would like to place another button in GridView named "Close" by which user can make that particular record "Non-editable". After clicking on close button on Gridview that record get locked and no body can edit that record in future.
Can anybody help me?

Maybe you can do that by adding a column to your table in your database. If the close button was clicked in your gridview, update the data in the database and make it closed so that it cannot be edit in your gridview.
Hope this gives you idea.

Related

Store GridView to session C#.Net [duplicate]

I have a page for searching when I write my name for example in textbox it will search and display the results in a GridView. I'm using an EntityDataSource with a QueryExtender so I didn't write any code in C#.
The problem is: in the GridView I have a hyperlink when I click it, it will go to another page, ok fine then when I return to the previous page the GridView does not show the results of the search when I was left because of the postback (update panel) it show the whole data from EntityDataSource.
I think I have to use session but I don't know how I can do it, I mean how I can save the GridView in session and how I can retrieve it in page_load.

How to insert, update, delete inside datagridview?

Hi guys I searched for lot on this topic but don't get any result. I want to know it is possible to add, update, delete inside datagridview in c# means i want to add new row and data inside the editable datagridview not from the forms control. I want to place Add New, edit, delete button or anything inside datagridview. In google there is lot of tutorials for this but from the form controls. This is possible in gridview control but i want to know this is also possible in datagridview or not If you have any link related to this then plz inform me. Thanks in advance!
You can Add new DataSet to your project, drag into it by DataSet Designer the table that you want edit with DataGridView by drag and drop from the Server Explorer to DataSet Designer, the runtime will create all the action to interact with you Dataset and TableAdapter, back into Form designer open Data Source Panel Drag your table under dataset to your Form .... done!
Next step it will call Update Method by single button here is the code:
this.nameOfYourTableAdapter.Update(this.nameOfYourDataSet.nameOfYourTable);
ref: Microsoft MSDN

how to handle row doubleclicking on GridView, and how to get the selected row

I am working on a MVC application. My requirement is as below.
Add/Edit/ Delete functionality (done this using editor template). Done
Display read-only information on double click of row. - Need Solution.
Delete selected row in button click
Description: The user should be able to view the details of a row by double clicking the row. Double clicking the row should display the details in read-only mode.
Then the other problem is how can i be able to select a row and delete it by button click.
Please let me know how I can achieve this functionality.
Usually something like is achieved with javascript/jQuery.
You would bring down the read-only data when the page is first loaded but hidden from view. Then set it up so that when you double click a row the extra information is displayed through modifying the CSS display value.
It would be equally as easy to show this information in another window - or wherever else you desire.
For more information take a look at the jQuery website

You must finish editing the current row gridview validation?

I am new to the wonderful world of asp.net gridviews. As of now, my gridview would have several rows each with a edit and update button. When I click edit, the editable cells turn into textboxes and can be successfully updated. However, if I am in edit mode in one row, and I click an update button in another row, an error will fire.
So my question is, how could I validate that the current row finished editing? Ive been searching google and I understand how to make field templates, assign a control, and can validate a certain cell. But I am not sure of a way to force someone to finish editing before causing that error. Thanks in advance!
From comments:
Why do you provide an update button when the row is not in edit mode?
You could set AutoGenerateEditButton to true. Then update + cancel buttons are shown when edit was clicked.

Undo records modified using gridview if user clicks Cancel

I've got a user modification page, that displays a list of reports a user has access to using a GridView object.
What I want to do is, if someone makes a bunch of changes to a users page, but then clicks cancel, all changes that are made will be undone.
My main issue here is the GridView, which has add/delete/modify buttons, tied to a separate table.
So if I open my own page, add a new report to the gridview, then hit cancel, I don't want that report to be saved to my account..
Likewise, if I delete a record, and then hit cancel, the record is not deleted.
What is the best way to do this?
You need to maintain this in the datatable and put this in a Session variable and bind your gridview to your datatable that is in the session. So once you are finished with the changes and want to submit the changes in the DB, you have to play with Datatable Row State, from which you can find which row is added and which one is Deleted or Modified.
Have a look at this article to understand Datatable Row state
system.data.datarow.rowstate
In such case you mustn't bind GridView to the real datasource (Entity framework). If you do it changes will be written to the database and you will have very hard time to roll them back. GridView must work with temporary data stored for example in the session and only after commiting changes (Save button on the page) the data will be written to the database by EF.

Categories