Subject: How does Update Link in FormView work? URGENT
Posted By: shaly Post Date: 12/7/2006 3:10:03 PM
Hi friends,

Somehow i am stuck at a very basic step. I have two pages  -


1. DomainList.aspx which just displays all the records from the Domains
table.
2. DomainAddEdit.aspx which displays the selected record in
FormView(Edit Mode) with two link for Update and Cancel.


The Update link in the FormView does nothing on the first click. It
just reloads the page with the new data I entered. If I click again on
the Update link, it throws me an error:


"Cannot insert the value NULL into column 'DNS', table
'MSInteractive.dbo.Domains'; column does not allow nulls. UPDATE fails.
The statement has been terminated. "


I have no clue why all this is happening. I have spent more than two
days on this and this is very very frustrating.


Just to mention, I haven't written any code for this. Its developed all
using the VWD tools available. I have posted this message earlier but
haven't got any response. I am sure most of you guys must have been
doing these steps everyday. So, please post your thoughts. Thanks a
million.


Here is the relevant code for my DomainADDEdit.aspx:


<asp:FormView ID="FormView1" runat="server"
DataSourceID="SqlDataSource1" DefaultMode="Edit">
        <EditItemTemplate>
            Id:
            <asp:TextBox ID="IdTextBox" runat="server" Text='<%#
Bind("Id") %>'></asp:TextBox><br />
            RegistrarAccountId:
            <asp:TextBox ID="RegistrarAccountIdTextBox" runat="server"
Text='<%# Bind("RegistrarAccountId") %>'></asp:TextBox><br />
            Registrar:
            <asp:TextBox ID="RegistrarTextBox" runat="server" Text='<%#
Bind("Registrar") %>'></asp:TextBox><br />
            DNS:
            <asp:TextBox ID="DNSTextBox" runat="server"
AutoPostBack="True" OnTextChanged="DNSTextBox_TextChanged"
                Text='<%# Bind("DNS") %>'></asp:TextBox><br />
            EmailHost:
            <asp:TextBox ID="EmailHostTextBox" runat="server" Text='<%#
Bind("EmailHost") %>'></asp:TextBox><br />
            Registered:
            <asp:TextBox ID="RegisteredTextBox" runat="server"
Text='<%# Bind("Registered") %>'></asp:TextBox><br />
            Expires:
            <asp:TextBox ID="ExpiresTextBox" runat="server" Text='<%#
Bind("Expires") %>'></asp:TextBox><br />
            MsiResponsible:
            <asp:CheckBox ID="MsiResponsibleCheckBox" runat="server"
Checked='<%# Bind("MsiResponsible") %>' />
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MSInteractiveConnectionString
%>"
        SelectCommand="SELECT [Id], [RegistrarAccountId], [Registrar],
[DNS], [EmailHost], [Registered], [Expires], [MsiResponsible] FROM
[Domains] WHERE ([Id] = @Id)"
        UpdateCommand="UPDATE Domains SET DNS = @txtDNS WHERE (Id =
@Id)">
        <UpdateParameters>
            <asp:FormParameter FormField="DNSTextBox" Name="txtDNS" />
            <asp:QueryStringParameter Name="Id" QueryStringField="Id"
/>
        </UpdateParameters>
        <SelectParameters>
            <asp:QueryStringParameter Name="Id" QueryStringField="Id"
Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
<br />
            <asp:LinkButton ID="UpdateButton" runat="server"
CommandName="Update"
                Text="Update"
OnClick="UpdateButton_Click"></asp:LinkButton>
            <asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
                Text="Cancel"></asp:LinkButton>
        </EditItemTemplate>





Go to topic 53312

Return to index page 99
Return to index page 98
Return to index page 97
Return to index page 96
Return to index page 95
Return to index page 94
Return to index page 93
Return to index page 92
Return to index page 91
Return to index page 90