Web application Listview question - c#

In a list view in C# how can I make all the fields in a column editable at once? Right now I have the standard edit button which allows me to update just one line at a time. I want the end user to be able to click a button and allow then to edit the column in its entirety.

Rebind the ListView with all TextBoxes when the user clicks edit.
You would have to manually track if you're in edit mode or not and on postback loop through all the rows retrieving the values from the textboxes and store them.
There is no built-in functionallity for what you're trying to do but it's possible.

Related

c# pass parameters from a previous action

I'm writing an application that will have a datagridview control and 4 textboxes.
One requirement for the application is that when the user double clicks a row in the datagrid, the 4 textboxes fill with the corresponding textboxes with the data -> this is already done and working. Once the user has edited the field and clicks OK, they will be saved on the datagridview.
On the other hand, if the user clicks a button called "Add Register", the same buttons will be enabled and once they click OK a new register with the data in the textboxes will be created.
The thing is that I don't know how and I have not found any information about knowing if I should edit a row (and which one) or add a new one when OK is clicked.
In other words: how can I know if I'm coming from an "edit" request or an "Add register" request when the user presses "OK"?
Thanks!
Welcome to StackOverflow.
The simplest way to achieve this is to have a boolean field on your form, e.g. bool isEdit. When the user double clicks a line in the DataGridView (a handler for which you say you have working), then set the field to true. Within the Add register button handler, set the field to false.
Now within your OK handler, you simply examine the value of the isEdit field to know, if you are adding or editing!
I have done a lot (a very great lot!) of such DataGridView forms. Personally I do not like to combine the form with data entry. I prefer to leave my DataGridView form as totally read-only, and then when the user clicks edit or add buttons, I display a separate modal form to handle the data entry. On saving from the modal form, I refresh the grid.
HTH

how to save a history point for a gridview in updatepanel in c#

I have a form which displays the data as per the search filters. Filters are few textboxes which allows the user to find the desired data.
Search button is the trigger for the update panel which contains Listview and the data is displayed as per the selected filters.Listview rows has a edit button. when i try to edit some record and come back by clicking the browser back button i dont find the List view anymore.
Is there a way wherein i can save the history point so that the Listview could be cashed and viewed quickly when i come back.
After few search i understood that scriptmanager enable history is set to true and history point is set.
But how to save the gridview data and display it back?
Can anyone help me out with this. Any example will help.

How to Track the Changes in every textbox and checkboxes and radio buttons in a forms

I have a form which has checkboxes, textboxes, comboboxes and radiobuttons. and I have a save button which will save the values of the above controls into the database.
Now I need to store the old value and controls and new values. that means need to store the history of changes in database. Im using WPF form and controls.
Any Idea?
You can make use of 'flags' for each control on your form.
handle change events of the controls, and if value is modified set the flag.
on Save button click, you can check if any flags are set, then you can save changes the way you want.
if u want to maintain the history of your update row use trigger on update.and store old value to your history table .
If I'm understanding your question correctly, you want to have a before and after of the values changed on a form. So let's say you were saving a person's contact information. When you load up this contact information you could make a copy of the class. Then when you click save, check the two instances to see what is different and save that in your history table.

Edit and delete rows in gridview

We know asp.net gridview can edit/delete by clicking the button along with the gridview bind with a database.
Can we do it in windows form? I mean how to customize the button event or borrow asp.net framework to winform?
Please see the image.
As far as I know the winform grid do not have these abilities, You'll have to create them explicitly, like add another column and implement his onlclick/doulbe click, it really have tons of events.
p.s. if u want the user to change values on the rows displayed you'll need this:
dataGridView1.EditMode = DataGridViewEditMode.EditOnKeystroke

swicth combobox to textbox

I have add a options form to my application. There is 2 radio buttons and when the options form is closing that form saves the data to database user is selected witch one of these radio buttons.
And I have another form is writing some data to database, user is selecting a item from combobox's list to add. I want to user can add that data manually too without of this combobox. When user select "manual" on options form, combobox must disappear and a textbox must appear and user is selected "list" then combobox must appear.
Hot can i do that? I need a new sql query too.
If it's just the two controls, one easy way of doing it would be to place both of them on the form, on top of each other, and then just make one of them invisible, and when the user selects the other options, just change visibility on both of them.
You'll have to make sure that your form closing code that saves the data reads from the correct control of course, but that's just the matter of a simple if statement to check which of them is visible.

Categories