473,756 Members | 8,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7335
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*********@di scussions.micro soft.comwrote in message
news:D4******** *************** ***********@mic rosoft.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*yah oo*dot*comwrote in message
news:O6******** ******@TK2MSFTN GP05.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
6336
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 correctly but it is not updating or deleting the rows. What I did was, in design view, added a gridview control and added an sqldatasource control. I configured the data source to update and delete. In the gridview tasks I selected enable...
3
2770
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 be fairly easy cos it's a build in feature of the gridview but alas... When the user clicks delete only one row on one table needs to be deleted thus I made a new query in my Datatable (DeleteissueQuery) that excpects an id
0
4349
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 need to be updated based on the data in the gridview. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:slightsInventoryConnectionString %>" SelectCommand="SELECT * FROM " UpdateCommand="upd_Inventory"...
3
3680
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 I can see in DataBidings property of the GridView I deliver SelectedIndex instead of SelectedValue. Therefore I gives SelectedIndex value to update in that specific field and NOT SelectedValue (it is ID - foreign key of parent table)
1
10406
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" OnRowCreated="ContactHistoryGrid_RowCreated" CssClass="GridViewTable" GridLines="None" CellSpacing="1" CellPadding="3" AllowSorting="True" AllowPaging="True"> <EmptyDataTemplate>
1
15046
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 to add controls dynamically as I am trying to write a reusable , general , spreadsheet like display control that can take advantage of the built- in update and delete features of the SqlDataSource/Gridview controls. This user control can get its...
1
1982
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 change True' and 'False' by 'Yes' and 'No' in normal mode. I tried this, but still get True / False. Thanks for help
4
6420
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 can I change it back to 'normal' mode, as if they clicked cancel? e.cancel = true doesnt seem to work. Thanks.
15
15831
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 mode and when i hit update the Datasource updates but the control will not return to readonly mode. I have gone far enough to figure out the problem is caused by the Checkbox field.The checkbox works and passes the correct true/false value to the...
0
9384
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9212
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9973
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9779
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6473
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5247
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2612
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.