473,322 Members | 1,403 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,322 software developers and data experts.

FormView control wiping data/not updating

Hi,

I've been trying for most of the day to get a FormView control to work.
I would like to display a single record, based on a unique user id
(loginid), which I am retreiving from a cookie. No paging involved. I
want to give the user the ability to edit their record and update it (no
insert).

I pre-populate the database fields with values, and when I execute the
page, it wipes out the corresponding database field values belonging to
the user with matching loginid (it replaces phone, country, state,
postcode, company, title values with blanks).

If I click the edit button and put values into the fields, then click
update button, this doesn't work either. There are still blanks in the
database fields.

If anyone could please offer a solution I would REALLY appreciate it. I
have looked for hours and cannot see what I am doing wrong.

I'm not using any code in my code behind related to this control. Here
is my code...

<asp:FormView runat="server" ID="FormView1" AllowPaging="false"
DefaultMode="ReadOnly" DataSourceID="SqlDataSource3"
DataKeyNames="LoginID" BorderWidth="0">
<ItemTemplate>
<table runat="server" width="350" border="0"
cellspacing="5"
style="border-top-width: 0px;
border-left-width: 0px; border-bottom-width: 0px; border-collapse:
collapse; border-right-width: 0px; background-color:#F6F6F6"
id="tblFormItem" align="left">
<tr>
<td align="left" colspan="2">
<asp:Label runat="server" CssClass="qtext"
ID="lblfvname" Text='<%# Eval("name") %>' />
<asp:Label runat="server" ID="lblfvlogin"
Text='<%# Eval("LoginID") %>' />
</td>
</tr>
<tr>
<td align="left">
<asp:Label runat="server" CssClass="bodytext"
ID="lblfvco" Text='<%# Eval("company") %>' />
&nbsp;<asp:Label runat="server"
CssClass="bodytext" ID="lblfvtitle" Text='<%# Eval("title") %>' />
</td>
<td align="left">
<asp:Label runat="server" CssClass="bodytext"
ID="lblfvphone" Text='<%# Eval("phone") %>' />
</td>
</tr>
<tr>
<td align="left">
<asp:Label runat="server" CssClass="bodytext"
ID="lblfvstate" Text='<%# Eval("state") %>' />
&nbsp;<asp:Label runat="server"
CssClass="bodytext" ID="lblfvcountry" Text='<%# Eval("country") %>' />
&nbsp;<asp:Label runat="server"
CssClass="bodytext" ID="lblfvpcode" Text='<%# Eval("postcode") %>' />
</td>
<td align="left">
<asp:Label runat="server" CssClass="bodytext"
ID="lblfvemail" Text='<%# Eval("email") %>' />
</td>
</tr>
<tr>
<td align="left">
<asp:ImageButton ImageUrl="~/images/update.jpg"
CommandName="Edit" runat="server" ID="btnFormview1" />
</td>
<td>
&nbsp;
</td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table runat="server" width="350" border="0"
cellspacing="5"
style="border-top-width: 0px;
border-left-width: 0px; border-bottom-width: 0px; border-collapse:
collapse; border-right-width: 0px; background-color:#F6F6F6"
id="tblFormEdit" align="left">
<tr>
<td align="left" colspan="2">
<asp:Label runat="server" ID="txtNamefv"
CssClass="qtext" Text='<%# Eval("name") %>' />
<asp:label ID="txtLoginIDfv" runat="server"
Text='<%# Eval("LoginID") %>' />
</td>
</tr>
<tr>
<td align="left">
<asp:textbox runat="server" CssClass="bodytext"
ID="txtCompanyfv" Text='<%# Bind("company") %>' />
&nbsp;<asp:textbox runat="server"
ID="txtTitlefv" CssClass="bodytext" Text='<%# Bind("title") %>' />
</td>
<td align="left">
<asp:textbox runat="server" ID="txtPhonefv"
CssClass="bodytext" Text='<%# Bind("phone") %>' />
</td>
</tr>
<tr>
<td align="left">
<asp:textbox runat="server" ID="txtStatefv"
CssClass="bodytext" Text='<%# Bind("state") %>' />
&nbsp;<asp:textbox runat="server"
ID="txtCountryfv" CssClass="bodytext" Text='<%# Bind("country") %>' />
&nbsp;<asp:textbox runat="server"
ID="txtPostcodefv" CssClass="bodytext" Text='<%# Bind("postcode") %>' />
</td>
<td align="left">
<asp:label runat="server" ID="lblEmailfv"
CssClass="bodytext" Text='<%# Eval("email") %>' />
</td>
</tr>
<tr>
<td align="left">
<asp:ImageButton ImageUrl="~/images/update.jpg"
CausesValidation="false" CommandName="Update" runat="server"
ID="btnFormviewUpdate" />
&nbsp;<asp:ImageButton
ImageUrl="~/images/cancel.jpg" CommandName="Cancel" runat="server"
ID="btnFormviewCancel" />
</td>
<td>
&nbsp;
</td>
</tr>
</table>
</EditItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString = "<%$ ConnectionStrings:AdminSqlServer %>"
SelectCommand="SELECT LoginID, Email,[first_name] + ' ' +
[last_name] as
Name,[phone],[country],[state],[postcode],[company],[title] FROM Profile
WHERE LoginID = @LoginID1"
UpdateCommand="UPDATE Profile SET phone = @phone, country =
@country, state = @state, postcode = @postcode, company = @company,
title = @title WHERE LoginID = @LoginID;" >
<SelectParameters>
<asp:ControlParameter ControlID="txtLID" Name="LoginID1"
PropertyName="Text" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="phone" Type="String" />
<asp:Parameter Name="country" Type="String" />
<asp:Parameter Name="state" Type="String" />
<asp:Parameter Name="postcode" Type="String" />
<asp:Parameter Name="company" Type="String" />
<asp:Parameter Name="title" Type="String" />
<asp:ControlParameter ControlID="txtLID" Name="LoginID"
PropertyName="Text" />
</UpdateParameters>
</asp:SqlDataSource>

*** Sent via Developersdex http://www.developersdex.com ***
Jul 22 '08 #1
0 1621

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michael Glass | last post by:
I'm working on an ASP.Net web app using VS2005 and the .Net 2.0 framework, and I have a serious problem with the page I'm currently working on. The page has, among other things, two FormViews and a...
2
by: P. Yanzick | last post by:
Hello, I am creating an edit template for a FormView control, changing one of the textboxes to a dropdown box. The dropdown will be populated from a simple table with the primary key, and a...
1
by: yuchang | last post by:
Hi, Using the FormView control is very efficient. But I want to do some action,like showing a success message or redirect to another page, after inserting, updating and deleting. How do I get...
1
by: Dabbler | last post by:
I have a FormView tied to ObjectDataSource that's not updating and am wondering what I missed.. <asp:FormView ID="fvRegDetail" runat="server" DefaultMode="Edit" DataKeyNames="RegistrantId"...
2
by: sck10 | last post by:
Hello, I have a SQL Server 2K table with a field set to currency. When I try to insert or update a FormView, I get the following error: Disallowed implicit conversion from data type nvarchar...
0
by: hardieca | last post by:
Hi, My formview or gridview control stops updating or deleting a record once the record has a null value. I have table tblTest with the following pkID int NOT NULL **IDENTITY COLUMN**...
3
by: J055 | last post by:
Hi I have a PlaceHolder control inside a FormView EditItemTemplate: <asp:PlaceHolder ID="phResponseText" runat="server"> <tr> <td> <asp:Label ID="lblResponseText"...
3
by: KaOne | last post by:
Hi All, excuse me in advance for my not very perfect english. I need some help about a problem with a FormView bounded to an ObjectDataSource. In practise I have an ObjectDataSource that uses some...
0
by: =?Utf-8?B?X3ByZWZpeA==?= | last post by:
Hello All, I have written a page with a sqlserverdatasource control and a formview web control. I want to use stored procedures to perform CRUD operations. Formview textboxes bind to table...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.