Home All Groups Group Topic Archive Search About

Need help with UpdateButton in FormView

Author
7 Dec 2006 7:29 PM
shaly
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>

AddThis Social Bookmark Button