473,543 Members | 2,348 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Gridview not updating the database

I setup a simple gridview as a utility just to do some updates, nothing fancy
just wanted easy UI to make updates. When I select ‘Edit’, I get the fields
I want to edit. I edit them and click ‘Update’, the page returns to its
original state (prior to clicking Edit) and no updates occur in the DB. What
am I missing? I included the html code below.
--
Thank-you,
Barbara Alderton

<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSou rce ID="DBNameSourc e" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:CONV_ADMINCo nnectionString %>"
SelectCommand=" SELECT DISTINCT [DBName] FROM
[CNV_CODE_MAPPIN G]"></asp:SqlDataSour ce>
<asp:SqlDataSou rce ID="TableSource " runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:CONV_ADMINCo nnectionString %>"
SelectCommand=" SELECT DISTINCT [TableName] FROM
[CNV_CODE_MAPPIN G] WHERE ([DBName] = @DBName)">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="ddDa taBases" Name="DBName"
PropertyName="S electedValue"
Type="String" />
</SelectParameter s>
</asp:SqlDataSour ce>
<asp:SqlDataSou rce ID="ForeignKeyS ource" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:CONV_ADMINCo nnectionString %>"
SelectCommand=" SELECT DISTINCT [ForeignKey] FROM
[CNV_CODE_MAPPIN G] WHERE (([DBName] = @DBName) AND ([TableName] =
@TableName))">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="ddDa taBases" Name="DBName"
PropertyName="S electedValue"
Type="String" />
<asp:ControlPar ameter ControlID="ddTa bles" Name="TableName "
PropertyName="S electedValue"
Type="String" />
</SelectParameter s>
</asp:SqlDataSour ce>
</div>
<asp:SqlDataSou rce ID="DataGridSou rce" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:CONV_ADMINCo nnectionString %>"
SelectCommand=" SELECT [Mapping_UID], [DBName], [TableName],
[ForeignKey], [UIDOld], [ValueOld], [DescOld], [CreateDate], [DescNew],
[ValueNew], [UIDNew], [LastChangeDate] FROM [CNV_CODE_MAPPIN G] WHERE
(([DBName] = @DBName) AND ([TableName] = @TableName) AND ([ForeignKey] =
@ForeignKey))" OldValuesParame terFormatString ="original_{ 0}"
DeleteCommand=" DELETE FROM [CNV_CODE_MAPPIN G] WHERE [Mapping_UID] =
@original_Mappi ng_UID" InsertCommand=" INSERT INTO [CNV_CODE_MAPPIN G]
([DBName], [TableName], [ForeignKey], [UIDOld], [ValueOld], [DescOld],
[CreateDate], [DescNew], [ValueNew], [UIDNew], [LastChangeDate]) VALUES
(@DBName, @TableName, @ForeignKey, @UIDOld, @ValueOld, @DescOld, @CreateDate,
@DescNew, @ValueNew, @UIDNew, @LastChangeDate )" UpdateCommand=" UPDATE
[CNV_CODE_MAPPIN G] SET [DBName] = @DBName, [TableName] = @TableName,
[ForeignKey] = @ForeignKey, [UIDOld] = @UIDOld, [ValueOld] = @ValueOld,
[DescOld] = @DescOld, [CreateDate] = @CreateDate, [DescNew] = @DescNew,
[ValueNew] = @ValueNew, [UIDNew] = @UIDNew, [LastChangeDate] =
@LastChangeDate WHERE [Mapping_UID] = @original_Mappi ng_UID">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="ddDa taBases" Name="DBName"
PropertyName="S electedValue"
Type="String" />
<asp:ControlPar ameter ControlID="ddTa bles" Name="TableName "
PropertyName="S electedValue"
Type="String" />
<asp:ControlPar ameter ControlID="ddFo reignKeys"
Name="ForeignKe y" PropertyName="S electedValue"
Type="String" />
</SelectParameter s>
<DeleteParamete rs>
<asp:Paramete r Name="original_ Mapping_UID" Type="Int32" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="DBName" Type="String" />
<asp:Paramete r Name="TableName " Type="String" />
<asp:Paramete r Name="ForeignKe y" Type="String" />
<asp:Paramete r Name="UIDOld" Type="Int32" />
<asp:Paramete r Name="ValueOld" Type="String" />
<asp:Paramete r Name="DescOld" Type="String" />
<asp:Paramete r Name="CreateDat e" Type="DateTime" />
<asp:Paramete r Name="DescNew" Type="String" />
<asp:Paramete r Name="ValueNew" Type="String" />
<asp:Paramete r Name="UIDNew" Type="Int32" />
<asp:Paramete r Name="LastChang eDate" Type="DateTime" />
<asp:Paramete r Name="original_ Mapping_UID" Type="Int32" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Name="DBName" Type="String" />
<asp:Paramete r Name="TableName " Type="String" />
<asp:Paramete r Name="ForeignKe y" Type="String" />
<asp:Paramete r Name="UIDOld" Type="Int32" />
<asp:Paramete r Name="ValueOld" Type="String" />
<asp:Paramete r Name="DescOld" Type="String" />
<asp:Paramete r Name="CreateDat e" Type="DateTime" />
<asp:Paramete r Name="DescNew" Type="String" />
<asp:Paramete r Name="ValueNew" Type="String" />
<asp:Paramete r Name="UIDNew" Type="Int32" />
<asp:Paramete r Name="LastChang eDate" Type="DateTime" />
</InsertParameter s>
</asp:SqlDataSour ce>

<table style="width: 800px">
<tr>
<td style="width: 800px">
<table style="width: 790px">
<tr>
<td style="width: 150px">
</td>
<td style="text-align: center; width: 490px">
<span style="font-family: Arial"><strong> Code Mapping
Tool</strong></span></td>
<td style="width: 150px">
</td>
</tr>
<tr>
<td style="height: 21px">
</td>
<td style="height: 21px">
</td>
<td style="height: 21px">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width: 800px">
<table style="width: 400px">
<tr>
<td style="width: 167px">
<asp:Label ID="Label1" runat="server"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
Text="DataBase Name:"
Width="120px"></asp:Label></td>
<td style="width: 200px">
<asp:DropDownLi st ID="ddDataBases "
runat="server" AutoPostBack="T rue" DataSourceID="D BNameSource"
DataTextField=" DBName"
DataValueField= "DBName">
</asp:DropDownLis t></td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 167px; height: 20px;">
<asp:Label ID="lblTblTag" runat="server"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
Text="Table Name:"></asp:Label></td>
<td style="width: 200px; height: 20px;">
<asp:DropDownLi st ID="ddTables"
runat="server" AutoPostBack="T rue" DataSourceID="T ableSource"
DataTextField=" TableName"
DataValueField= "TableName" >
</asp:DropDownLis t></td>
<td style="width: 100px; height: 20px;">
</td>
</tr>
<tr>
<td style="width: 167px">
<asp:Label ID="Label2" runat="server"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
Text="Foreign Key:"></asp:Label></td>
<td style="width: 200px">
<asp:DropDownLi st ID="ddForeignKe ys"
runat="server" AutoPostBack="T rue" DataSourceID="F oreignKeySource "
DataTextField=" ForeignKey"
DataValueField= "ForeignKey ">
</asp:DropDownLis t></td>
<td style="width: 100px">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width: 800px">
<table style="width: 790px">
<tr>
<td style="width: 50px">
</td>
<td style="width: 740px">
<asp:GridView ID="GridView1" runat="server"
AllowPaging="Tr ue" AllowSorting="T rue"
AutoGenerateCol umns="False"
BackColor="#CCC CCC" BorderColor="#9 99999" BorderStyle="So lid"
BorderWidth="3p x" CellPadding="4"
CellSpacing="2" DataSourceID="D ataGridSource"
ForeColor="Blac k">
<FooterStyle BackColor="#CCC CCC" />
<Columns>
<asp:BoundFie ld
DataField="Mapp ing_UID" HeaderText="Map ping_UID" InsertVisible=" False"
ReadOnly="True"
SortExpression= "Mapping_UI D" />
<asp:BoundFie ld
DataField="Tabl eName" HeaderText="Tab le Name" ReadOnly="True"
SortExpression= "TableName" >
<FooterStyle Width="50px" />
</asp:BoundField>
<asp:BoundFie ld
DataField="Fore ignKey" HeaderText="For eign Key" ReadOnly="True"
SortExpression= "ForeignKey " />
<asp:BoundFie ld DataField="UIDO ld"
HeaderText="Old UID" ReadOnly="True" SortExpression= "UIDOld" />
<asp:BoundFie ld DataField="Valu eOld"
HeaderText="Old Value" ReadOnly="True" SortExpression= "ValueOld" />
<asp:BoundFie ld DataField="Desc Old"
HeaderText="Old Desc" ReadOnly="True" SortExpression= "DescOld" />
<asp:BoundFie ld
DataField="Crea teDate" DataFormatStrin g="{0:d}" HeaderText="Cre ate Date"
HtmlEncode="Fal se"
ReadOnly="True" SortExpression= "CreateDate " />
<asp:BoundFie ld DataField="UIDN ew"
HeaderText="UID New" SortExpression= "UIDNew" />
<asp:BoundFie ld DataField="Valu eNew"
HeaderText="New Value" SortExpression= "ValueNew" />
<asp:BoundFie ld DataField="Desc New"
HeaderText="New Desc" SortExpression= "DescNew" />
<asp:BoundFie ld
DataField="Last ChangeDate" HeaderText="Las t Change Date"
SortExpression= "LastChangeDate " />
<asp:CommandFie ld
ShowEditButton= "True" />
</Columns>
<RowStyle BackColor="Whit e" />
<SelectedRowSty le BackColor="#000 099"
Font-Bold="True" ForeColor="Whit e" />
<PagerStyle BackColor="#CCC CCC"
ForeColor="Blac k" HorizontalAlign ="Left" />
<HeaderStyle BackColor="Blac k"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
ForeColor="Whit e" />
</asp:GridView>
</td>
</tr>
<tr>
<td style="width: 50px">
</td>
<td style="width: 740px">
</td>
</tr>
<tr>
<td style="width: 50px">
</td>
<td style="width: 740px">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>

Jun 15 '07 #1
4 8737
It looks like you are not setting DataKeyNames property for the GridView.
This property represents the primary key (or comma separated if composite PK)
for the table bound to the grid and GridView needs this info for automatic
update or delete.

Also from MSDN: "You must set the DataKeyNames property for the automatic
updating and deleting features of the GridView control to work. The values of
these key fields are passed to the data source control in order to match the
row to update or delete."

"Barbara Alderton" wrote:
I setup a simple gridview as a utility just to do some updates, nothing fancy
just wanted easy UI to make updates. When I select ‘Edit’, I get the fields
I want to edit. I edit them and click ‘Update’, the page returns to its
original state (prior to clicking Edit) and no updates occur in the DB. What
am I missing? I included the html code below.
--
Thank-you,
Barbara Alderton

<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSou rce ID="DBNameSourc e" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:CONV_ADMINCo nnectionString %>"
SelectCommand=" SELECT DISTINCT [DBName] FROM
[CNV_CODE_MAPPIN G]"></asp:SqlDataSour ce>
<asp:SqlDataSou rce ID="TableSource " runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:CONV_ADMINCo nnectionString %>"
SelectCommand=" SELECT DISTINCT [TableName] FROM
[CNV_CODE_MAPPIN G] WHERE ([DBName] = @DBName)">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="ddDa taBases" Name="DBName"
PropertyName="S electedValue"
Type="String" />
</SelectParameter s>
</asp:SqlDataSour ce>
<asp:SqlDataSou rce ID="ForeignKeyS ource" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:CONV_ADMINCo nnectionString %>"
SelectCommand=" SELECT DISTINCT [ForeignKey] FROM
[CNV_CODE_MAPPIN G] WHERE (([DBName] = @DBName) AND ([TableName] =
@TableName))">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="ddDa taBases" Name="DBName"
PropertyName="S electedValue"
Type="String" />
<asp:ControlPar ameter ControlID="ddTa bles" Name="TableName "
PropertyName="S electedValue"
Type="String" />
</SelectParameter s>
</asp:SqlDataSour ce>
</div>
<asp:SqlDataSou rce ID="DataGridSou rce" runat="server"
ConnectionStrin g="<%$ ConnectionStrin gs:CONV_ADMINCo nnectionString %>"
SelectCommand=" SELECT [Mapping_UID], [DBName], [TableName],
[ForeignKey], [UIDOld], [ValueOld], [DescOld], [CreateDate], [DescNew],
[ValueNew], [UIDNew], [LastChangeDate] FROM [CNV_CODE_MAPPIN G] WHERE
(([DBName] = @DBName) AND ([TableName] = @TableName) AND ([ForeignKey] =
@ForeignKey))" OldValuesParame terFormatString ="original_{ 0}"
DeleteCommand=" DELETE FROM [CNV_CODE_MAPPIN G] WHERE [Mapping_UID] =
@original_Mappi ng_UID" InsertCommand=" INSERT INTO [CNV_CODE_MAPPIN G]
([DBName], [TableName], [ForeignKey], [UIDOld], [ValueOld], [DescOld],
[CreateDate], [DescNew], [ValueNew], [UIDNew], [LastChangeDate]) VALUES
(@DBName, @TableName, @ForeignKey, @UIDOld, @ValueOld, @DescOld, @CreateDate,
@DescNew, @ValueNew, @UIDNew, @LastChangeDate )" UpdateCommand=" UPDATE
[CNV_CODE_MAPPIN G] SET [DBName] = @DBName, [TableName] = @TableName,
[ForeignKey] = @ForeignKey, [UIDOld] = @UIDOld, [ValueOld] = @ValueOld,
[DescOld] = @DescOld, [CreateDate] = @CreateDate, [DescNew] = @DescNew,
[ValueNew] = @ValueNew, [UIDNew] = @UIDNew, [LastChangeDate] =
@LastChangeDate WHERE [Mapping_UID] = @original_Mappi ng_UID">
<SelectParamete rs>
<asp:ControlPar ameter ControlID="ddDa taBases" Name="DBName"
PropertyName="S electedValue"
Type="String" />
<asp:ControlPar ameter ControlID="ddTa bles" Name="TableName "
PropertyName="S electedValue"
Type="String" />
<asp:ControlPar ameter ControlID="ddFo reignKeys"
Name="ForeignKe y" PropertyName="S electedValue"
Type="String" />
</SelectParameter s>
<DeleteParamete rs>
<asp:Paramete r Name="original_ Mapping_UID" Type="Int32" />
</DeleteParameter s>
<UpdateParamete rs>
<asp:Paramete r Name="DBName" Type="String" />
<asp:Paramete r Name="TableName " Type="String" />
<asp:Paramete r Name="ForeignKe y" Type="String" />
<asp:Paramete r Name="UIDOld" Type="Int32" />
<asp:Paramete r Name="ValueOld" Type="String" />
<asp:Paramete r Name="DescOld" Type="String" />
<asp:Paramete r Name="CreateDat e" Type="DateTime" />
<asp:Paramete r Name="DescNew" Type="String" />
<asp:Paramete r Name="ValueNew" Type="String" />
<asp:Paramete r Name="UIDNew" Type="Int32" />
<asp:Paramete r Name="LastChang eDate" Type="DateTime" />
<asp:Paramete r Name="original_ Mapping_UID" Type="Int32" />
</UpdateParameter s>
<InsertParamete rs>
<asp:Paramete r Name="DBName" Type="String" />
<asp:Paramete r Name="TableName " Type="String" />
<asp:Paramete r Name="ForeignKe y" Type="String" />
<asp:Paramete r Name="UIDOld" Type="Int32" />
<asp:Paramete r Name="ValueOld" Type="String" />
<asp:Paramete r Name="DescOld" Type="String" />
<asp:Paramete r Name="CreateDat e" Type="DateTime" />
<asp:Paramete r Name="DescNew" Type="String" />
<asp:Paramete r Name="ValueNew" Type="String" />
<asp:Paramete r Name="UIDNew" Type="Int32" />
<asp:Paramete r Name="LastChang eDate" Type="DateTime" />
</InsertParameter s>
</asp:SqlDataSour ce>

<table style="width: 800px">
<tr>
<td style="width: 800px">
<table style="width: 790px">
<tr>
<td style="width: 150px">
</td>
<td style="text-align: center; width: 490px">
<span style="font-family: Arial"><strong> Code Mapping
Tool</strong></span></td>
<td style="width: 150px">
</td>
</tr>
<tr>
<td style="height: 21px">
</td>
<td style="height: 21px">
</td>
<td style="height: 21px">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width: 800px">
<table style="width: 400px">
<tr>
<td style="width: 167px">
<asp:Label ID="Label1" runat="server"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
Text="DataBase Name:"
Width="120px"></asp:Label></td>
<td style="width: 200px">
<asp:DropDownLi st ID="ddDataBases "
runat="server" AutoPostBack="T rue" DataSourceID="D BNameSource"
DataTextField=" DBName"
DataValueField= "DBName">
</asp:DropDownLis t></td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 167px; height: 20px;">
<asp:Label ID="lblTblTag" runat="server"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
Text="Table Name:"></asp:Label></td>
<td style="width: 200px; height: 20px;">
<asp:DropDownLi st ID="ddTables"
runat="server" AutoPostBack="T rue" DataSourceID="T ableSource"
DataTextField=" TableName"
DataValueField= "TableName" >
</asp:DropDownLis t></td>
<td style="width: 100px; height: 20px;">
</td>
</tr>
<tr>
<td style="width: 167px">
<asp:Label ID="Label2" runat="server"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
Text="Foreign Key:"></asp:Label></td>
<td style="width: 200px">
<asp:DropDownLi st ID="ddForeignKe ys"
runat="server" AutoPostBack="T rue" DataSourceID="F oreignKeySource "
DataTextField=" ForeignKey"
DataValueField= "ForeignKey ">
</asp:DropDownLis t></td>
<td style="width: 100px">
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="width: 800px">
<table style="width: 790px">
<tr>
<td style="width: 50px">
</td>
<td style="width: 740px">
<asp:GridView ID="GridView1" runat="server"
AllowPaging="Tr ue" AllowSorting="T rue"
AutoGenerateCol umns="False"
BackColor="#CCC CCC" BorderColor="#9 99999" BorderStyle="So lid"
BorderWidth="3p x" CellPadding="4"
CellSpacing="2" DataSourceID="D ataGridSource"
ForeColor="Blac k">
<FooterStyle BackColor="#CCC CCC" />
<Columns>
<asp:BoundFie ld
DataField="Mapp ing_UID" HeaderText="Map ping_UID" InsertVisible=" False"
ReadOnly="True"
SortExpression= "Mapping_UI D" />
<asp:BoundFie ld
DataField="Tabl eName" HeaderText="Tab le Name" ReadOnly="True"
SortExpression= "TableName" >
<FooterStyle Width="50px" />
</asp:BoundField>
<asp:BoundFie ld
DataField="Fore ignKey" HeaderText="For eign Key" ReadOnly="True"
SortExpression= "ForeignKey " />
<asp:BoundFie ld DataField="UIDO ld"
HeaderText="Old UID" ReadOnly="True" SortExpression= "UIDOld" />
<asp:BoundFie ld DataField="Valu eOld"
HeaderText="Old Value" ReadOnly="True" SortExpression= "ValueOld" />
<asp:BoundFie ld DataField="Desc Old"
HeaderText="Old Desc" ReadOnly="True" SortExpression= "DescOld" />
<asp:BoundFie ld
DataField="Crea teDate" DataFormatStrin g="{0:d}" HeaderText="Cre ate Date"
HtmlEncode="Fal se"
ReadOnly="True" SortExpression= "CreateDate " />
<asp:BoundFie ld DataField="UIDN ew"
HeaderText="UID New" SortExpression= "UIDNew" />
<asp:BoundFie ld DataField="Valu eNew"
HeaderText="New Value" SortExpression= "ValueNew" />
<asp:BoundFie ld DataField="Desc New"
HeaderText="New Desc" SortExpression= "DescNew" />
<asp:BoundFie ld
DataField="Last ChangeDate" HeaderText="Las t Change Date"
SortExpression= "LastChangeDate " />
<asp:CommandFie ld
ShowEditButton= "True" />
</Columns>
<RowStyle BackColor="Whit e" />
<SelectedRowSty le BackColor="#000 099"
Font-Bold="True" ForeColor="Whit e" />
<PagerStyle BackColor="#CCC CCC"
ForeColor="Blac k" HorizontalAlign ="Left" />
<HeaderStyle BackColor="Blac k"
Font-Bold="True" Font-Names="Arial" Font-Size="11pt"
ForeColor="Whit e" />
</asp:GridView>
</td>
</tr>
<tr>
<td style="width: 50px">
</td>
<td style="width: 740px">
</td>
</tr>
<tr>
<td style="width: 50px">
</td>
<td style="width: 740px">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
Jun 15 '07 #2
Hi Barbara,

As Siva pointed out, you need to set GridView.DataKe yNames to the PK of the
database table, in your case, which is the "Mapping_UI D":

<asp:GridView DataKeyNames="M apping_UID" ...
Please try this and let us know the result. Thanks.
Reference:

#GridView.DataK eyNames Property (System.Web.UI. WebControls)
http://msdn2.microsoft.com/en-us/lib...trols.gridview.
datakeynames.as px
You must set the DataKeyNames property for the automatic updating and
deleting features of the GridView control to work. The values of these key
fields are passed to the data source control in order to match the row to
update or delete.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 15 '07 #3
I set the datakeynames value and I then got another error regarding my update
statement. I modified to just update the editable fields and all worked
fine. This is my first exposure to the new gridview in asp.net 2.0,
previously worked with the datagrid in 1.1. I don't usually depend on auto
generated items in .net, there is usually something I need to add or change.
This was just supposed to be a quick little page I setup for myself to make
another task easier.

Thanks for the quick responses.

--
Thank-you,
Barbara Alderton
"Walter Wang [MSFT]" wrote:
Hi Barbara,

As Siva pointed out, you need to set GridView.DataKe yNames to the PK of the
database table, in your case, which is the "Mapping_UI D":

<asp:GridView DataKeyNames="M apping_UID" ...
Please try this and let us know the result. Thanks.
Reference:

#GridView.DataK eyNames Property (System.Web.UI. WebControls)
http://msdn2.microsoft.com/en-us/lib...trols.gridview.
datakeynames.as px
You must set the DataKeyNames property for the automatic updating and
deleting features of the GridView control to work. The values of these key
fields are passed to the data source control in order to match the row to
update or delete.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 15 '07 #4
Hi Barbara,

If you're new to the ASP.NET 2.0's new data related controls, you may find
following resource useful:

#Working with Data and ASP.NET 2.0: ASP.NET Web: The Official Microsoft
ASP.NET 2.0 Site
http://www.asp.net/learn/dataaccess/....aspx?tabid=63
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 18 '07 #5

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

Similar topics

0
1229
by: Mike P | last post by:
I want to update my gridview, but rather than specifying the Update Parameters etc in the GridView, I want to use my own code similar to the way I updated the DataGrid v1.1. I also want to make a call to a seperate data class to do this. Here is my code : protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) {
3
4155
by: Bren | last post by:
Hi All VS2005 Gridview control with vb I am populating a gridview of company staff. One of the columns is a hyperlink to a SMS texting facility I have so secrataries can text the managers etc. i.e Secratary loads the page on the intranet, finds the manager they want to contact, clicks on the "SMS" hyperlink and is taken to the SMS page...
0
832
by: tulasikumar | last post by:
Hi all I am using gridview control and when I try to update a row having empty values with updatecommand. I am unable to update please help me out.. Thanks in advance Best Regards, TulasiKumar
0
1479
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm trying to update a row in my gridview. i loaded the gridview from an xml file (dataset.readxml). now i'm trying to wire up all the CRUD events and i'm having trouble with the update event. Here was my first instinct which doesn't work: protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e) {
2
1405
by: gomzi | last post by:
Hi, I would like to know as to how I could accomplish the task of automatically updating my users gridview when I insert a new row in my database. i.e. Suppose I insert a new row in a database, then all the user's griview should display that new row without them having to refresh their page. i.e. Something like gmail or microsoft's outlook. ...
0
2210
by: lamolap | last post by:
i have 1 gridview , a dropdownlist inside a gridview and a commandfield of (edit, update and cancel) my gidview looks like this Edit Surname Initials ParkingBay CommandField Me Y dropdownlistvalue CommandField You ...
3
1567
by: nguyenlh | last post by:
code: I have read a example :The use girdview without datasource <asp:GridView AutoGenerateColumns="false" ID="GridView1" runat="server" OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating"> <Columns> <asp:CommandField ShowEditButton="true" /> <asp:BoundField...
0
1172
by: Kalkin | last post by:
Hi i am having trouble with the following problem any help would be appreciated:: The gridview starts off with empty text boxes for input along with already populated dropdowns to choose from for input. This is all fine, but when it has saved and needs to be called back to the same gridview how do i get it to choose from the dropdown list the...
4
2345
by: abdulaziz68 | last post by:
I have gridview in asp.net ( c# ) , and i have to column in gridview 1st column it's a number and 2nd column it's a color , and I use SQL server database and I used sqldatasource in asp.net .. The question ? I wont the color in 2nd column depending the value from database ,since I saved in the database color name for example : 1 red 2...
0
7408
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, well explore What is ONU, What Is Router, ONU & Routers main...
0
7735
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7688
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5885
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5271
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...
0
3391
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1817
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
968
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
636
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...

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.