GridView not updating changes

T

teclioness

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="ProcFrameworkEvidenceSelectALLByDeptId"
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!!
 
P

Pipo

Have you specified the DataKeys?

teclioness said:
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="ProcFrameworkEvidenceSelectALLByDeptId"
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!!
 
T

teclioness

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.
 
T

teclioness

Hi,
Would I still be able to use the Sqldatasource update feature? Is there
any example you can help me with?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top