By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,376 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

GridView not updating changes

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
You could use the GridView's RowEditing and RowUpdating events.

Apr 19 '06 #5

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.