472,961 Members | 1,548 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,961 software developers and data experts.

Change gridview from Update to Normal mode.

VB.NET

How do you change a gridview from Update mode to normal mode? I'm usually
dealing for Formviews and there is a ChangeMode option but I don't see one
for Gridviews.
Aug 6 '07 #1
3 7286
Hi,
An important property that plays a special role in Update and Delete
operations is the DataKeyNames property. This property is typically set to
the names of fields from the data source that are part of a primary key used
to match a given row in the data source. Multiple keys are comma-separated
when specifying this property declaratively, although it is common to only
have one primary key field. The values of fields specified by the
DataKeyNames property are round-tripped in viewstate for the sake of
retaining original values to pass to an Update or Delete operation, even if
that field is not rendered as one of the columns in the GridView control.
When the GridView invokes the data source Update or Delete operation, it
passes the values of these fields to the data source in a special Keys
dictionary, separate from the Values dictionary that contains new values
entered by the user while the row is in edit mode (for update operations).
The contents of the Values dictionary are obtained from the input controls
rendered for the row in edit mode. To exclude a value from this dictionary,
set the ReadOnly property to true on the corresponding BoundField in the
Column collection. If you are using the GridView designer in Visual Studio,
the ReadOnly property is set to true for primary key fields by default.
ref:http://quickstarts.asp.net/QuickStar.../gridview.aspx
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"pvong" wrote:
VB.NET

How do you change a gridview from Update mode to normal mode? I'm usually
dealing for Formviews and there is a ChangeMode option but I don't see one
for Gridviews.
Aug 6 '07 #2
I read this, but I'm still confused. I understand the concept of how it
happens, but I don't understand how to make it happen.
"Manish Bafna" <Ma*********@discussions.microsoft.comwrote in message
news:D4**********************************@microsof t.com...
Hi,
An important property that plays a special role in Update and Delete
operations is the DataKeyNames property. This property is typically set to
the names of fields from the data source that are part of a primary key
used
to match a given row in the data source. Multiple keys are comma-separated
when specifying this property declaratively, although it is common to only
have one primary key field. The values of fields specified by the
DataKeyNames property are round-tripped in viewstate for the sake of
retaining original values to pass to an Update or Delete operation, even
if
that field is not rendered as one of the columns in the GridView control.
When the GridView invokes the data source Update or Delete operation, it
passes the values of these fields to the data source in a special Keys
dictionary, separate from the Values dictionary that contains new values
entered by the user while the row is in edit mode (for update operations).
The contents of the Values dictionary are obtained from the input controls
rendered for the row in edit mode. To exclude a value from this
dictionary,
set the ReadOnly property to true on the corresponding BoundField in the
Column collection. If you are using the GridView designer in Visual
Studio,
the ReadOnly property is set to true for primary key fields by default.
ref:http://quickstarts.asp.net/QuickStar.../gridview.aspx
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"pvong" wrote:
>VB.NET

How do you change a gridview from Update mode to normal mode? I'm
usually
dealing for Formviews and there is a ChangeMode option but I don't see
one
for Gridviews.

Aug 6 '07 #3
Please help me. This is the only missing step for me.

Simple Gridview that when I hit Edit, I get Textboxes for editing. I have
inserted my own ADO.NET for the Update button and it works perfectly. I
just want the gridview to go back to normal view after it has updated. So
after Update, turn gridview back to original format where the textboxes are
labels again and you have the option to hit Edit again.

"pvong" <phillip*at*yahoo*dot*comwrote in message
news:O6**************@TK2MSFTNGP05.phx.gbl...
VB.NET

How do you change a gridview from Update mode to normal mode? I'm usually
dealing for Formviews and there is a ChangeMode option but I don't see one
for Gridviews.

Aug 7 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data...
3
by: tarscher | last post by:
Hi all, I have a grid that contains 7 columns from 3 tables (3 unique keys, 4 normal fields). I show this 7 columns on the gridview. I now want to add edit and delete functionality. This should...
0
by: troyblakely | last post by:
I have a gridview which is pulling data from a SqlDataSource, the select command queries a view and the update command is a stored procedure. I'm using a stored procedure because several tables...
3
by: Dariusz Tomon | last post by:
Hello, I have GridView in EditItem Template of DetailsView (in normal - read-only mode there is a label). When I'm in edit mode I can select one item from GridView. The main problem is that as...
1
by: Evan M. | last post by:
Here's my GridView and my SqlDataSource <asp:GridView ID="ContactHistoryGrid" runat="server" AutoGenerateColumns="False" DataSourceID="ContactHistoryDS" DataKeyNames="JobHistoryID"...
1
by: savajx1 | last post by:
I need to dynamically create a set of bound fields contained in a GridView control. I also have a single static CommandField that I can declare in the Columns <tagof the GridView control. I have...
1
by: Ben | last post by:
Hi, The gridview contains a radiobuttonlist with boolean values (true/false) coming from a database. In normal mode, the gridview displays True or False for that field. What i want is to...
4
by: Bobby Edward | last post by:
I have some custom rowupdating code in my gridview. The user clicks edit, edits the record, clicks update and it runs my code. The code runs fine but the row is still in an 'update' mode. How...
15
by: stefbek97 | last post by:
Hello All, I am having Trouble with a Gridview control In my asp.net/C# application. It contains Some boundFields and one checkbox field. My gridview allows Editing. It succesfully enters edit...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.