Hi,
Delete is working fine for me, but Update- Nothing is happening. Please find the code snippet below and help me out... - <asp:GridView ID="empGrid" runat="server" AllowSorting="True" AutoGenerateColumns="False"
-
DataSourceID="empTestDataSource" >
-
<Columns>
-
<asp:ButtonField CommandName="Select" ButtonType=Link DataTextField="empId" />
-
<asp:BoundField DataField="empName" HeaderText="empName" SortExpression="empName" />
-
<asp:BoundField DataField="empAge" HeaderText="empAge" SortExpression="empAge" />
-
<asp:CommandField ShowEditButton=true ButtonType=Button />
-
<asp:CommandField ShowDeleteButton=true ButtonType=Button />
-
</Columns>
-
</asp:GridView>
-
<asp:AccessDataSource ID="empTestDataSource" runat="server" DataFile="~/Database/Employee.mdb"
-
SelectCommand="SELECT [empName], [empAge], [empId] FROM [emp]"
-
UpdateCommand="UPDATE emp SET empName=@empName WHERE empId=@empId"
-
DeleteCommand="DELETE FROM emp WHERE empId=@empId" OldValuesParameterFormatString="{0}">
-
<UpdateParameters>
-
<asp:Parameter Name="empName" Type=string />
-
<asp:Parameter Name="empId" Type=Int32 />
-
</UpdateParameters>
-
</asp:AccessDataSource>
Any help would be appreciated....
thnks in advance...
9 25673
How are you executing the update statement?
On clicking the delete button, i get the row deleted from the DB. But, Update is not working as it is suppsoed to work. I am not getting any error, the page returns with the original values.
Am i missing something in the code? Pls help...
Somebody pls help....
I am using a simple Gridview to display the emp id (as a link for selecting), emp name, emp Age. There are edit and delete buttons in each row. Using the delete button, the record can be deleted. But the Edit-Update/Cancel functinality is not working. I am not getting any errors. The old values are not updated with the new values. This is the scenario. The code is once more put for reference...PLS HELP !!! -
<table width="500px"><tr><td>
-
<div style="margin:5px; margin-top:5px">
-
<div class="smallfont" style="margin-bottom:2px">Code:</div>
-
<pre class="alt2 smallcode" style="margin:0px; padding:6px; border:1px inset; width: 500px; overflow:scroll"><div dir="ltr" style="text-align:left;"><asp:GridView ID="empGrid" runat="server" AllowSorting="True" AutoGenerateColumns="False"
-
DataSourceID="empTestDataSource" >
-
<Columns>
-
<asp:ButtonField CommandName="Select" ButtonType=Link DataTextField="empId" />
-
<asp:BoundField DataField="empName" HeaderText="empName" SortExpression="empName" />
-
<asp:BoundField DataField="empAge" HeaderText="empAge" SortExpression="empAge" />
-
<asp:CommandField ShowEditButton=true ButtonType=Button />
-
<asp:CommandField ShowDeleteButton=true ButtonType=Button />
-
</Columns>
-
</asp:GridView>
-
<asp:AccessDataSource ID="empTestDataSource" runat="server" DataFile="~/Database/Employee.mdb"
-
SelectCommand="SELECT [empName], [empAge], [empId] FROM [emp]"
-
UpdateCommand="UPDATE emp SET empName=@empName WHERE empId=@empId"
-
DeleteCommand="DELETE FROM emp WHERE empId=@empId" OldValuesParameterFormatString="{0}">
-
<UpdateParameters>
-
<asp:Parameter Name="empName" Type=string />
-
<asp:Parameter Name="empId" Type=Int32 />
-
</UpdateParameters>
-
</asp:AccessDataSource></div></pre>
-
</div>
-
</td></tr></table><br />
Are you refreshing the dataqsource? Otherwise gridview is going ti display same values.
Are you refreshing the dataqsource? Otherwise gridview is going ti display same values.
But the value is not getting updated in the database even.
And how do we refresh a datasource? Pls help...
I was thinking that if your gridview is rebound then the updated data would be displayed. You indicate that it is the former so that your update command isn't executing. Here is an article that may help: ASP.NET GridView - Add a new record
I had the same problem. I found that in Visual Web Developer I had to specify the "DataKeyNames" property of the GridView as the primary key for my database table.
So the primary key for my database table was "id". So I clicked on the GridView and in the Properties tab, I typed "id" (no quotes) in the "DataKeyNames" box.
Hope that helps,
marloutor
Thanks! This was very helpful.
I had the same problem. I found that in Visual Web Developer I had to specify the "DataKeyNames" property of the GridView as the primary key for my database table.
So the primary key for my database table was "id". So I clicked on the GridView and in the Properties tab, I typed "id" (no quotes) in the "DataKeyNames" box.
Hope that helps,
marloutor
I also had a problem with a GridView that was not updating. Inspection of the e.Newvalues Dictionary in the GridView's RowUpdating event showed that the old values for the record were being sent to the database UPDATE query. DataKeyNames was not my problem; I had it set correctly. The WHERE clause of my SELECT query referenced a control parameter against a TextBox on my form. I had inadvertently set EnableViewState for this textbox to "False". Because of this, the GridView was rebinding itself before the UPDATE occurred. Setting EnableViewState on the TextBox to "True" fixed the problem. - Protected Sub MyGridView_RowUpdating _
-
(sender As Object, e As System.Web.UI.WebControls.GridViewUpdateEventArgs) _
-
Handles MyGridView.RowUpdating
-
-
' Inspect the parameters being sent to the database for an ASP NET GridView UPDATE.
-
-
Dim I As Integer
-
-
I = 0
-
-
For Each MVO As System.Collections.DictionaryEntry In e.OldValues
-
If MVO.Value Is DBNull.Value OrElse MVO.Value Is Nothing Then
-
Debug.Print(I.ToString + ": " + MVO.Key + " Value: ")
-
Else
-
Debug.Print(I.ToString + ": " + MVO.Key + " Value: " + MVO.Value.ToString)
-
End If
-
-
I += 1
-
Next MVO
-
-
I = 0
-
For Each MVN As System.Collections.DictionaryEntry In e.NewValues
-
If MVN.Value Is DBNull.Value OrElse MVN.Value Is Nothing Then
-
Debug.Print(I.ToString + ": " + MVN.Key + " Value: ")
-
Else
-
Debug.Print(I.ToString + ": " + MVN.Key + " Value: " + MVN.Value.ToString)
-
End If
-
I += 1
-
Next MVN
-
-
-
End Sub
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: NETDeveloper |
last post by:
Hi,
I almost have my nested datagrid working properly. I created a datagrid on a
user control and dropped that onto another datagrid. At first, I noticed when
I was stepping through the code,...
|
by: fatmosh |
last post by:
I have a GridView that is pulling data from a SQL database using a
Select command. I would like to use GridView's built-in "Edit, Update,
Cancel" functionality because it is very handy.
However,...
|
by: A_PK |
last post by:
Could anyone pls guide me what is wrong with my Update Command
Dim signbyte As Byte()
signbyte = GetByteArray() ' i create this function to return
ByteArray
Try
Dim cmd As New SqlCeCommand...
|
by: Nick |
last post by:
Hi all,
I'm trying to use an Update command in a Gridview.
I understand about the <asp:Parameter Name="blah" Type="String" /> however,
although this is telling .NET what type the parameter is,...
|
by: TJ |
last post by:
Hi All,
I am having some trouble.
I have created a database via the new database option inside VWD2005.
Then and table or two.
I have been able to perform INSERT and SELECT operations on...
|
by: =?Utf-8?B?V2ViQnVpbGRlcjQ1MQ==?= |
last post by:
i get this message when i attempt an update in a gridview where i create the
update manuelly.
"Updating is not supported by data source 'dsStkStdData' unless
UpdateCommand is specified. "
...
|
by: Selvakumar |
last post by:
hai friends,
I am new to .net programming. I did the inserting data into MS-access database but i couldn't able to perform the update command. I used only textbox and command button for inserting...
|
by: Brad Baker |
last post by:
I have a formview with a datasource that contains a select and update
command. The select statement works fine but the update command doesn't seem
to be working. After some troubleshooting I have...
|
by: Bobby Edward |
last post by:
I have a business object method called UpdateCategory that calls the Update
command of a xsd dataset I created.
The Update has 5 overloads: DataTable, DataSet, DataRow, DataRows(), Actual...
|
by: =?Utf-8?B?ZWdzZGFy?= |
last post by:
Hello, I'm trying to do an update in my gridview but it is not doing for
"Descripcion" it but with the other field "IdGrupo" it does and I need to
save both, how can I solve this:
This is my...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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...
| |