How do i only update 1 column in gridview? - asp.net

I have a gridview with multiple columns however I only want to update one of these columns in the database. I have set all other columns to read only so that the only editable field is the one I want to edit however when I update this field all others get deleted but I want them to remain the same. How do I accomplish this?
Thanks

Make the gridview fields TemplateFields, you can then access the EditItemTemplate of the fields. In the editItemTemplate, instead of Textbox( by default) you replace the textbox with a Label for the fields for which you don't want the edit facility.
similar question here http://forums.asp.net/t/1099084.aspx/1

When You are updating your data base values you can also update all other values which read only. and one editable column value change each time .

Related

How to pass dummy gridview column in <ASP:HyperLinkField> URL as querystring

I am facing problem in passing a dummy column's value in URL of <asp:HyperLinkField>.
My first column in gridview contains value from <%#Container.DataItemIndex+1> which gridview is populating however on click on my 2nd column which is a hyperlink field i want to pass value from 1st columns generated by <%#Container.DataItemIndex+1>.
So the problem here i am facing is how to pass a value as querystring which is not getting populated from database however is available as column in gridview.
Thanks in advance,
Can you paste the code so i can detect the problem and tell you what to do. Cos one thing you need to understand is the gridview tend itemize cell as zero index. So if your intention is to get say the ID of a table to a linkfieldbutton, i will advice you to use LinkButton.
Assuming I understood your question:
Have you tried binding column 2 to the same field (DataField) column1 is so you can use the (same) data any way you want.
Alternatively, perhaps you can (already) use column1 for the same purpose (re: display and link)?
Hth....

How I can add checked rows from grid view to another girdview in asp.net c#

I have two GridViews. The first grid view's first column is a checkbox.
How can I populate a second grid with the values of the checked rows from the first grid?
For this you need to have a for loop for taking all the rows together and one after another you need to check for the checkbox check property and for all those which are checked you need to add them into another dataset and then you have to assign that dataset to another grid.
You can find detailed narrative here,
http://www.aspsnippets.com/Articles/Transfer-Selected-Rows-from-one-GridView-to-Another-in-Asp.net.aspx

Edit first column of GridView

I've got very dynamic GridView and I need to allow to user to edit first column of it. After he edit first column of grid it must be updated on DataBase.
Is there any ways to handle it ?
My only idea is to put some changeable element to first cell of each Row so it must be able to set / get my values for each row but can't find yet any examples of it ...
Additional info :
GridView takes data from Object data source and all columns are dynamic (yes, maybe except first, but I add it in dynamic way) and load complete DataTable... \
Currently Using jQuery+Ajax methode on dynamic button but can't disable button's PostBack so with a PostBack it just disappears and dont make the event it must to make...
Since you have dymanic columns, for each column, specify the read-only property (If a column is read-only, it may only be looked at, and not edited when in the GridView's Edit-Mode).
So, the first column of would be readonly="false" (or omit it entirely) and the other columns read-only="true".

How to Display a DataGrid with Insert Mode without any pre-filled data?

How to display the datagrid in insert mode without any data in it.
The GridView is empty and contains only one header.
I want to insert the data in the GridView when the application is running.
What you could do is using an empty Binding Source to a List which would enable you to add new Rows.
Check out some samples of how to use the Binding Source here
Please have a look at these 2 examples:
Insert rows with a GridView
Adding Insert Capabilities to the GridView
I don't think the datagrid will be rendered if its data source is empty. To work around this problem you can give it a data source with only one item that is regarded as empty (for example a data table with one row where all columns have empty values). You can then check for this special case in your program logic.

Get Changed Rows of GridView ASP.Net

How Can I find all the rows that has been changed in gridview. I can not use Ajax in any form
First get the contents of your grid before it was changed (such as caching the results of the original gridview datasource binding). Then go through the dataset/datatable/however you want to store it, and compare the contents with the current rows of the gridview.
There's no real efficient way to do this, no method like GridView.GetAllChangedRows(). So, what you might do instead is keep a behind the scenes List that you add to each time a row is modified (use the RowUpdated method), then clear this list when needed.
It depends upon how many columns you want to edit in a row.
If you have only one editable column in a row then you can associate a javascript method with that control which you want to modify and in that method you can get a rowid which you can save in another hidden field and in server side you can get all rows whose ids are stored in hidden field.
If you have whole row editable in that case the best approach I think you should save the original data source somewhere and also set a javascript method with rowclick event to get rowid which user selects. Then when user clicks on submit button get all rows whose row ids are stored in hidden field then compare those with same rowid in datasource. This is the best approach from my point of you.
Let me give you an example, suppose there are 1000 rows in a grid and user clicks on only 180 rows. In that case we will compare only 180 rows and wont compare rest of the rows.
Please let me know if somebody has better idea then this.

Resources