Howdy,
I have a DetailsView that when I fire the UpdateItem event, it doesn't
update the data. The page reloads and the data is set back to the original.
I'm using a Button to fire the UpdateItem event and then leaves the user a
status stating that the event is updated, which does occur so i know the
button is firing properly. I haven't tried InsertItem yet, going to set that
up now. Any ideas why this is happening? My code is below.
Thanks
David Lozzi
<asp:DetailsView ID="dvDetails" runat="server" AutoGenerateRows="False"
DataSourceID="SqlDataSource1" BorderWidth="0px" DefaultMode="Edit">
<Fields>
<asp:BoundField DataField="strTitle" HeaderText="Title"
SortExpression="strTitle" />
<asp:TemplateField HeaderText="strDescription"
SortExpression="strDescription">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("strDescription")
%>' Columns="60" Rows="3" TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("strDescription")
%>' Columns="60" Rows="3" TextMode="MultiLine"></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("strDescription")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="dtDate" HeaderText="Date" SortExpression="dtDate"
/>
<asp:BoundField DataField="strSpeaker" HeaderText="Speaker"
SortExpression="strSpeaker" />
<asp:BoundField DataField="strHost" HeaderText="Host"
SortExpression="strHost" />
<asp:BoundField DataField="strLocation" HeaderText="Location"
SortExpression="strLocation" />
<asp:BoundField DataField="strAddress" HeaderText="Address"
SortExpression="strAddress" />
<asp:BoundField DataField="strCity" HeaderText="City"
SortExpression="strCity" />
<asp:BoundField DataField="strState" HeaderText="State"
SortExpression="strState" />
<asp:BoundField DataField="strContactName" HeaderText="Contact Name"
SortExpression="strContactName" />
<asp:BoundField DataField="strContactTitle" HeaderText="Contact Title"
SortExpression="strContactTitle" />
<asp:BoundField DataField="strContactPhone" HeaderText="Contact Phone"
SortExpression="strContactPhone" />
<asp:BoundField DataField="strContactEmail" HeaderText="Contact Email"
SortExpression="strContactEmail" />
<asp:TemplateField HeaderText="strNotes" SortExpression="strNotes">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("strNotes") %>'
Columns="60" Rows="5" TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("strNotes") %>'
Columns="60" Rows="5" TextMode="MultiLine"></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("strNotes")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="dtModified" HeaderText="Modified" ReadOnly="True"
SortExpression="dtModified" />
<asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<br />
<asp:Button ID="btnUpdate" runat="server" Text="Update" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
<asp:Button ID="btnDone" runat="server" Text="Done" Visible="False" />
<asp:Label ID="lblStatus" runat="server" CssClass="required"></asp:Label><br
/>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$
ConnectionStrings:SMALLConnectionString %>"
SelectCommand="SELECT * FROM [tblEvents] WHERE ([ID] = @ID)"
DeleteCommand="DELETE FROM [tblEvents] WHERE [ID] = @ID"
InsertCommand="INSERT INTO [tblEvents] ([strTitle], [strDescription],
[dtDate], [strSpeaker], [strHost], [strLocation], [strAddress], [strCity],
[strState], [strContactName], [strContactTitle], [strContactPhone],
[strContactEmail], [strNotes], [dtAdded], [dtModified]) VALUES (@strTitle,
@strDescription, @dtDate, @strSpeaker, @strHost, @strLocation, @strAddress,
@strCity, @strState, @strContactName, @strContactTitle, @strContactPhone,
@strContactEmail, @strNotes, {fn Now()}, {fn Now()})"
UpdateCommand="UPDATE [tblEvents] SET [strTitle] = @strTitle,
[strDescription] = @strDescription, [dtDate] = @dtDate, [strSpeaker] =
@strSpeaker, [strHost] = @strHost, [strLocation] = @strLocation,
[strAddress] = @strAddress, [strCity] = @strCity, [strState] = @strState,
[strContactName] = @strContactName, [strContactTitle] = @strContactTitle,
[strContactPhone] = @strContactPhone, [strContactEmail] = @strContactEmail,
[strNotes] = @strNotes, [dtModified] = {fn Now()} WHERE [ID] = @ID">
<SelectParameters>
<asp:QueryStringParameter Name="ID" QueryStringField="EID" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="strTitle" Type="String" />
<asp:ControlParameter ControlID="dvDetails$TextBox1" PropertyName="Text"
Name="strDescription" Type="string" />
<asp:Parameter Name="dtDate" Type="DateTime" />
<asp:Parameter Name="strSpeaker" Type="String" />
<asp:Parameter Name="strHost" Type="String" />
<asp:Parameter Name="strLocation" Type="String" />
<asp:Parameter Name="strAddress" Type="String" />
<asp:Parameter Name="strCity" Type="String" />
<asp:Parameter Name="strState" Type="String" />
<asp:Parameter Name="strContactName" Type="String" />
<asp:Parameter Name="strContactTitle" Type="String" />
<asp:Parameter Name="strContactPhone" Type="String" />
<asp:Parameter Name="strContactEmail" Type="String" />
<asp:ControlParameter ControlID="dvDetails$TextBox2" PropertyName="Text"
Name="strNotes" Type="string" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="strTitle" Type="String" />
<asp:Parameter Name="strDescription" Type="String" />
<asp:Parameter Name="dtDate" Type="DateTime" />
<asp:Parameter Name="strSpeaker" Type="String" />
<asp:Parameter Name="strHost" Type="String" />
<asp:Parameter Name="strLocation" Type="String" />
<asp:Parameter Name="strAddress" Type="String" />
<asp:Parameter Name="strCity" Type="String" />
<asp:Parameter Name="strState" Type="String" />
<asp:Parameter Name="strContactName" Type="String" />
<asp:Parameter Name="strContactTitle" Type="String" />
<asp:Parameter Name="strContactPhone" Type="String" />
<asp:Parameter Name="strContactEmail" Type="String" />
<asp:Parameter Name="strNotes" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
dvDetails.UpdateItem(False)
btnDone.Visible = True
lblStatus.Text = "Event was updated successfully."
End Sub 2 5011
I went ahead and deleted the detailsview and the sqldatasource and recreated
and it works great now...
"David Lozzi" <dl****@nospam.nospamwrote in message
news:%2***************@TK2MSFTNGP02.phx.gbl...
Howdy,
I have a DetailsView that when I fire the UpdateItem event, it doesn't
update the data. The page reloads and the data is set back to the
original. I'm using a Button to fire the UpdateItem event and then leaves
the user a status stating that the event is updated, which does occur so i
know the button is firing properly. I haven't tried InsertItem yet, going
to set that up now. Any ideas why this is happening? My code is below.
Thanks
David Lozzi
<asp:DetailsView ID="dvDetails" runat="server" AutoGenerateRows="False"
DataSourceID="SqlDataSource1" BorderWidth="0px" DefaultMode="Edit">
<Fields>
<asp:BoundField DataField="strTitle" HeaderText="Title"
SortExpression="strTitle" />
<asp:TemplateField HeaderText="strDescription"
SortExpression="strDescription">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("strDescription")
%>' Columns="60" Rows="3" TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("strDescription")
%>' Columns="60" Rows="3" TextMode="MultiLine"></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("strDescription")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="dtDate" HeaderText="Date"
SortExpression="dtDate" />
<asp:BoundField DataField="strSpeaker" HeaderText="Speaker"
SortExpression="strSpeaker" />
<asp:BoundField DataField="strHost" HeaderText="Host"
SortExpression="strHost" />
<asp:BoundField DataField="strLocation" HeaderText="Location"
SortExpression="strLocation" />
<asp:BoundField DataField="strAddress" HeaderText="Address"
SortExpression="strAddress" />
<asp:BoundField DataField="strCity" HeaderText="City"
SortExpression="strCity" />
<asp:BoundField DataField="strState" HeaderText="State"
SortExpression="strState" />
<asp:BoundField DataField="strContactName" HeaderText="Contact Name"
SortExpression="strContactName" />
<asp:BoundField DataField="strContactTitle" HeaderText="Contact Title"
SortExpression="strContactTitle" />
<asp:BoundField DataField="strContactPhone" HeaderText="Contact Phone"
SortExpression="strContactPhone" />
<asp:BoundField DataField="strContactEmail" HeaderText="Contact Email"
SortExpression="strContactEmail" />
<asp:TemplateField HeaderText="strNotes" SortExpression="strNotes">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("strNotes") %>'
Columns="60" Rows="5" TextMode="MultiLine"></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("strNotes") %>'
Columns="60" Rows="5" TextMode="MultiLine"></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("strNotes")
%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="dtModified" HeaderText="Modified"
ReadOnly="True" SortExpression="dtModified" />
<asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<br />
<asp:Button ID="btnUpdate" runat="server" Text="Update" />
<asp:Button ID="btnCancel" runat="server" Text="Cancel" />
<asp:Button ID="btnDone" runat="server" Text="Done" Visible="False" />
<asp:Label ID="lblStatus" runat="server"
CssClass="required"></asp:Label><br />
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:SMALLConnectionString %>"
SelectCommand="SELECT * FROM [tblEvents] WHERE ([ID] = @ID)"
DeleteCommand="DELETE FROM [tblEvents] WHERE [ID] = @ID"
InsertCommand="INSERT INTO [tblEvents] ([strTitle], [strDescription],
[dtDate], [strSpeaker], [strHost], [strLocation], [strAddress], [strCity],
[strState], [strContactName], [strContactTitle], [strContactPhone],
[strContactEmail], [strNotes], [dtAdded], [dtModified]) VALUES (@strTitle,
@strDescription, @dtDate, @strSpeaker, @strHost, @strLocation,
@strAddress, @strCity, @strState, @strContactName, @strContactTitle,
@strContactPhone, @strContactEmail, @strNotes, {fn Now()}, {fn Now()})"
UpdateCommand="UPDATE [tblEvents] SET [strTitle] = @strTitle,
[strDescription] = @strDescription, [dtDate] = @dtDate, [strSpeaker] =
@strSpeaker, [strHost] = @strHost, [strLocation] = @strLocation,
[strAddress] = @strAddress, [strCity] = @strCity, [strState] = @strState,
[strContactName] = @strContactName, [strContactTitle] = @strContactTitle,
[strContactPhone] = @strContactPhone, [strContactEmail] =
@strContactEmail, [strNotes] = @strNotes, [dtModified] = {fn Now()} WHERE
[ID] = @ID">
<SelectParameters>
<asp:QueryStringParameter Name="ID" QueryStringField="EID" Type="Int32" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="ID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="strTitle" Type="String" />
<asp:ControlParameter ControlID="dvDetails$TextBox1" PropertyName="Text"
Name="strDescription" Type="string" />
<asp:Parameter Name="dtDate" Type="DateTime" />
<asp:Parameter Name="strSpeaker" Type="String" />
<asp:Parameter Name="strHost" Type="String" />
<asp:Parameter Name="strLocation" Type="String" />
<asp:Parameter Name="strAddress" Type="String" />
<asp:Parameter Name="strCity" Type="String" />
<asp:Parameter Name="strState" Type="String" />
<asp:Parameter Name="strContactName" Type="String" />
<asp:Parameter Name="strContactTitle" Type="String" />
<asp:Parameter Name="strContactPhone" Type="String" />
<asp:Parameter Name="strContactEmail" Type="String" />
<asp:ControlParameter ControlID="dvDetails$TextBox2" PropertyName="Text"
Name="strNotes" Type="string" />
<asp:Parameter Name="ID" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="strTitle" Type="String" />
<asp:Parameter Name="strDescription" Type="String" />
<asp:Parameter Name="dtDate" Type="DateTime" />
<asp:Parameter Name="strSpeaker" Type="String" />
<asp:Parameter Name="strHost" Type="String" />
<asp:Parameter Name="strLocation" Type="String" />
<asp:Parameter Name="strAddress" Type="String" />
<asp:Parameter Name="strCity" Type="String" />
<asp:Parameter Name="strState" Type="String" />
<asp:Parameter Name="strContactName" Type="String" />
<asp:Parameter Name="strContactTitle" Type="String" />
<asp:Parameter Name="strContactPhone" Type="String" />
<asp:Parameter Name="strContactEmail" Type="String" />
<asp:Parameter Name="strNotes" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btnUpdate.Click
dvDetails.UpdateItem(False)
btnDone.Visible = True
lblStatus.Text = "Event was updated successfully."
End Sub
"David Lozzi" <dl****@nospam.nospamwrote in message
news:us**************@TK2MSFTNGP06.phx.gbl...
went ahead and
:-) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: TdarTdar |
last post by:
HI,
I have a asp 2.0 page that has a sqldatasource and a detailsview i have
enabled the inserting updating deleting in the datasoure. I have a blank
table that has no records. I run the page.. I...
|
by: Andrew Robinson |
last post by:
Is there any way to accomplish two way data binding in a Details View with a
DataSet or DataTable as the DataSource.
All I want is to get an updated DataSet or DataTable back from the...
|
by: Jim Hammond |
last post by:
I am passing the whole object instead or parameters in my select and update
methods.
I can get the updated object if I set UpdateMethod, let ASP.NET autogenerate
an update button, and then press...
|
by: stuart.d.jones |
last post by:
Hi,
I have a DetailsView control bound to a SqlDataSource. I've got
everything working nearly as I want, but here's my problem.
I have a table which has a Guid as a Primary Key, and a VarChar...
|
by: 47computers |
last post by:
Whenever I Update a record with a DetailsView, after the postback the
DetailsView reverts to Insert mode and all the fields are blank. Is
there any way, perhaps in the ItemUpdated event, that I...
|
by: John |
last post by:
Hi
I have a DetailsView that is bound to a sql server. Problem is when I press
the auto generated Edit button make some change and press the Update link I
get the below error;
Updating is not...
|
by: =?Utf-8?B?U2F2dm91bGlkaXMgSW9yZGFuaXM=?= |
last post by:
In VS2008, I have a DetailsView control with a checkboxlist control inside
its Edit template.
(1) I want the checkboxlist to be dynamic and display only as many
checkboxes as a user setting is...
|
by: Dan |
last post by:
Hi,
I have a detailsview with two fields: in editmode, one is a textbox and the
other is a dropdownlist.
i want to update both fields using the detailsview.
My problem: when clicking on the...
|
by: bednarz.thomas |
last post by:
I have the following business Object(s):
public class ParentObject
{
public ParentObject(string somestring)
{
...-
}
....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: 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...
|
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,...
|
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: 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...
|
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,...
| |