473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

GridView not updating changes

Hi,

I am using gridview and sql datasource for select and update. When I
click on edit link against the records, the row is shows in edit mode.
When I make a change to it, the change is not updated and no errors
returned.
Here is the source.. Please help.

<asp:GridView ID="gvEvidence" runat="server" AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False" BackColor="LightGoldenrodYellow"
BorderColor="Tan"
BorderWidth="1px" CellPadding="2" Font-Bold="False"
Font-Overline="False" Font-Size="1.25em" ForeColor="Black"
Width="100%" DataKeyNames="FrameworkEvidenceId"
DataSourceID="DSEvidenceForAction">
<FooterStyle BackColor="Tan" Font-Size="1.2em" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="ActionMasterDisplayNo"
HeaderText="Action No." SortExpression="ActionMasterDisplayNo"
ReadOnly="True" />
<asp:BoundField DataField="ActionMasterDesc"
HeaderText="Action" SortExpression="ActionMasterDesc" ReadOnly="True"
/>
<asp:TemplateField HeaderText="Achieved"
SortExpression="FrameworkEvidenceAchieved"
ConvertEmptyStringToNull="False">
<EditItemTemplate>
<asp:DropDownList ID="cboAchieved" runat="server"
SelectedValue='<%# Bind("FrameworkEvidenceAchieved") %>'>
<asp:ListItem Selected="True"
Value="yes">Yes</asp:ListItem>
<asp:ListItem Value="no">No</asp:ListItem>
<asp:ListItem Value="partial progress">Partial
Progress</asp:ListItem>
<asp:ListItem Value="not applicable">Not
Applicable</asp:ListItem>
<asp:ListItem
Value="-">--Select--</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("FrameworkEvidenceAchieved") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Evidence"
SortExpression="FrameworkEvidenceDesc"
ConvertEmptyStringToNull="False">
<EditItemTemplate>
<asp:TextBox ID="txtEvidenceDesc" runat="server"
Text='<%# Bind("FrameworkEvidenceDesc") %>'
TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%#
Bind("FrameworkEvidenceDesc") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Evidence Ref"
SortExpression="FrameworkEvidenceRef" ConvertEmptyStringToNull="False">
<EditItemTemplate>
<asp:TextBox ID="txtEvidenceRef" runat="server"
MaxLength="150" Text='<%# Bind("FrameworkEvidenceRef")
%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%#
Bind("FrameworkEvidenceRef") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Updated By"
SortExpression="FrameworkEvidenceUpdatedBy"
ConvertEmptyStringToNull="False">
<EditItemTemplate>
&nbsp;<asp:Label ID="lblUpdatedBy" runat="server"
Text="<%# GetLoggedInUserId() %>"></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%#
Bind("FrameworkEvidenceUpdatedBy") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date"
SortExpression="FrameworkEvidenceUpdatedDate"
ConvertEmptyStringToNull="False">
<EditItemTemplate>
<asp:Label ID="lblUpdatedDate" runat="server"
Text="<%# now() %>"></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%#
Bind("FrameworkEvidenceUpdatedDate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<SelectedRowStyle BackColor="DarkSlateBlue"
ForeColor="GhostWhite" Font-Size="1.25em" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue"
HorizontalAlign="Center" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
<EditRowStyle BackColor="Gold" BorderColor="HotTrack"
Font-Size="1.25em" />
<EmptyDataTemplate>
Sorry, no data available.
</EmptyDataTemplate>
<EmptyDataRowStyle Font-Size="1.25em" />
</asp:GridView>
<asp:SqlDataSource ID="DSEvidenceForAction" runat="server"
ConnectionString="<%$ ConnectionStrings:EqualitiesDbConn %>"
SelectCommand="ProcFrameworkEvidenceSelectALLByDep tId"
SelectCommandType="StoredProcedure" UpdateCommand="UPDATE
dbo.FrameworkEvidence SET FrameworkEvidenceAchieved =
@evidenceAchieved, FrameworkEvidenceRef = @evidenceRef,
FrameworkEvidenceDesc = @evidenceDesc, FrameworkEvidenceUpdatedBy =
@updatedBy, FrameworkEvidenceUpdatedDate = @updatedDate WHERE
(FrameworkEvidenceId = @frameid)">
<SelectParameters>
<asp:Parameter DefaultValue="3" Name="dept_id" Type="Int64"
/>
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="evidenceAchieved" Type="String" />
<asp:Parameter Name="evidenceRef" Type="String" />
<asp:Parameter Name="evidenceDesc" Type="String" />
<asp:Parameter Name="updatedBy" Type="String" />
<asp:Parameter Name="updatedDate" Type="DateTime" />
<asp:Parameter Name="frameid" Type="Int64" />
</UpdateParameters>
</asp:SqlDataSource>

Thanks in advance!!

Apr 18 '06 #1
5 5413
Have you specified the DataKeys?

"teclioness" <gu********@gmail.com> wrote in message
news:11*********************@z34g2000cwc.googlegro ups.com...
Hi,

I am using gridview and sql datasource for select and update. When I
click on edit link against the records, the row is shows in edit mode.
When I make a change to it, the change is not updated and no errors
returned.
Here is the source.. Please help.

<asp:GridView ID="gvEvidence" runat="server" AllowPaging="True"
AllowSorting="True"
AutoGenerateColumns="False" BackColor="LightGoldenrodYellow"
BorderColor="Tan"
BorderWidth="1px" CellPadding="2" Font-Bold="False"
Font-Overline="False" Font-Size="1.25em" ForeColor="Black"
Width="100%" DataKeyNames="FrameworkEvidenceId"
DataSourceID="DSEvidenceForAction">
<FooterStyle BackColor="Tan" Font-Size="1.2em" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="ActionMasterDisplayNo"
HeaderText="Action No." SortExpression="ActionMasterDisplayNo"
ReadOnly="True" />
<asp:BoundField DataField="ActionMasterDesc"
HeaderText="Action" SortExpression="ActionMasterDesc" ReadOnly="True"
/>
<asp:TemplateField HeaderText="Achieved"
SortExpression="FrameworkEvidenceAchieved"
ConvertEmptyStringToNull="False">
<EditItemTemplate>
<asp:DropDownList ID="cboAchieved" runat="server"
SelectedValue='<%# Bind("FrameworkEvidenceAchieved") %>'>
<asp:ListItem Selected="True"
Value="yes">Yes</asp:ListItem>
<asp:ListItem Value="no">No</asp:ListItem>
<asp:ListItem Value="partial progress">Partial
Progress</asp:ListItem>
<asp:ListItem Value="not applicable">Not
Applicable</asp:ListItem>
<asp:ListItem
Value="-">--Select--</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("FrameworkEvidenceAchieved") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Evidence"
SortExpression="FrameworkEvidenceDesc"
ConvertEmptyStringToNull="False">
<EditItemTemplate>
<asp:TextBox ID="txtEvidenceDesc" runat="server"
Text='<%# Bind("FrameworkEvidenceDesc") %>'
TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%#
Bind("FrameworkEvidenceDesc") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Evidence Ref"
SortExpression="FrameworkEvidenceRef" ConvertEmptyStringToNull="False">
<EditItemTemplate>
<asp:TextBox ID="txtEvidenceRef" runat="server"
MaxLength="150" Text='<%# Bind("FrameworkEvidenceRef")
%>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%#
Bind("FrameworkEvidenceRef") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Updated By"
SortExpression="FrameworkEvidenceUpdatedBy"
ConvertEmptyStringToNull="False">
<EditItemTemplate>
&nbsp;<asp:Label ID="lblUpdatedBy" runat="server"
Text="<%# GetLoggedInUserId() %>"></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%#
Bind("FrameworkEvidenceUpdatedBy") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date"
SortExpression="FrameworkEvidenceUpdatedDate"
ConvertEmptyStringToNull="False">
<EditItemTemplate>
<asp:Label ID="lblUpdatedDate" runat="server"
Text="<%# now() %>"></asp:Label>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%#
Bind("FrameworkEvidenceUpdatedDate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<SelectedRowStyle BackColor="DarkSlateBlue"
ForeColor="GhostWhite" Font-Size="1.25em" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue"
HorizontalAlign="Center" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<AlternatingRowStyle BackColor="PaleGoldenrod" />
<EditRowStyle BackColor="Gold" BorderColor="HotTrack"
Font-Size="1.25em" />
<EmptyDataTemplate>
Sorry, no data available.
</EmptyDataTemplate>
<EmptyDataRowStyle Font-Size="1.25em" />
</asp:GridView>
<asp:SqlDataSource ID="DSEvidenceForAction" runat="server"
ConnectionString="<%$ ConnectionStrings:EqualitiesDbConn %>"
SelectCommand="ProcFrameworkEvidenceSelectALLByDep tId"
SelectCommandType="StoredProcedure" UpdateCommand="UPDATE
dbo.FrameworkEvidence SET FrameworkEvidenceAchieved =
@evidenceAchieved, FrameworkEvidenceRef = @evidenceRef,
FrameworkEvidenceDesc = @evidenceDesc, FrameworkEvidenceUpdatedBy =
@updatedBy, FrameworkEvidenceUpdatedDate = @updatedDate WHERE
(FrameworkEvidenceId = @frameid)">
<SelectParameters>
<asp:Parameter DefaultValue="3" Name="dept_id" Type="Int64"
/>
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="evidenceAchieved" Type="String" />
<asp:Parameter Name="evidenceRef" Type="String" />
<asp:Parameter Name="evidenceDesc" Type="String" />
<asp:Parameter Name="updatedBy" Type="String" />
<asp:Parameter Name="updatedDate" Type="DateTime" />
<asp:Parameter Name="frameid" Type="Int64" />
</UpdateParameters>
</asp:SqlDataSource>

Thanks in advance!!

Apr 18 '06 #2
Hi,

Yes, I tried with the datakeys as well. Still no errors and not
updating either..
Don't understand what I am doing wrong...

Any help would be appreciated.

Apr 19 '06 #3
I found the solution. I had to name the parameters the same name as the
ones that I was getting in select query. The following article helped
me:

http://www.whitworth.org/Blog/Commen...2d2fc191e.aspx

But I have another issue. In last 2 columns, I have to show the logged
in person's windows IId and the current date, when the person cliks on
edit and save to database when user clicks on update.

Please help!!!

Apr 19 '06 #4
You could use the GridView's RowEditing and RowUpdating events.

Apr 19 '06 #5
Hi,
Would I still be able to use the Sqldatasource update feature? Is there
any example you can help me with?

Apr 19 '06 #6

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...
1
by: MasterChief | last post by:
Is it possible to select an item on a gridview by clicking on it and then being able to click a link for example that says EditOrder in a treeview and have the EditOrder page open up viewing what...
0
by: Michael Kellogg | last post by:
I have a problem wherein a query that updates a GridView doesn't seem to really stay in sync with a label I have above the GridView. I have a GridView object that I'm updating with information...
3
by: pblack9455 | last post by:
I have a simple requirement to bind a small ArrayList of (ItemLine) Objects to a GridView control. The Gridview renders on the page and allows me to click update/edit buttons...however the data...
3
by: cpnet | last post by:
I have a GridView which I'm populating from an ObjectDataSource (give the GridView a DataTable). The GridView will have about 20 rows, and only one editable column. The editable column consists...
0
by: =?Utf-8?B?TGFkaXNsYXYgTXJua2E=?= | last post by:
Hello, I read some msdn and other articles about how does databinding among DataSource controls and FormView / GridView controls works but I still don't fully understand to this blackbox. I have...
1
by: Japskunk | last post by:
I am having trouble updating a SQL table through the GridView "Auto" Enable Edit Feature... I am connecting to a SQL 2000 Server with a SQLDataSource I have created the Update Query in the Command...
2
by: McGeeky | last post by:
Hi. Is there an example available for GridViews that demonstrate how they can support paging and updating? E.g. say I make some changes in the first page of data on a GridView then switch to...
1
by: David C | last post by:
I have a new GridView that has an SQL table as a datasource. The primary key is included but not visible. When I click the Edit link button, change a column's data and click Update, nothing...
11
by: SAL | last post by:
Hello, I have a Gridview control (.net 2.0) that I'm having trouble getting the Update button to fire any kind of event or preforming the update. The datatable is based on a join so I don't know...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
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,...
0
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...
0
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...
0
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 project—planning, coding, testing,...

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.