i have field (advDetails) in database with datatype TEXT,
and i am trying to insert text from asp.net detailsview into database but it isn't working.

here is my code.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="advertisementSubmission.aspx.cs" Inherits="advertisementSubmission" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:DetailsView ID="DetailsView1" runat="server" AccessKey="d" 
            AutoGenerateRows="False" DataKeyNames="advid" DataSourceID="SqlDataSource1" 
            DefaultMode="Insert" Height="50px" Width="125px" CellPadding="4" 
            ForeColor="#333333" GridLines="None">
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
            <Fields> 
                <asp:BoundField DataField="advid" HeaderText="advid" InsertVisible="False" 
                    ReadOnly="True" SortExpression="advid" />
                <asp:BoundField DataField="advtitle" HeaderText="advtitle" 
                    SortExpression="advtitle" />
                <asp:BoundField DataField="startingdate" HeaderText="startingdate" 
                    SortExpression="startingdate" />
                <asp:BoundField DataField="endingdate" HeaderText="endingdate" 
                    SortExpression="endingdate" />
                <asp:BoundField DataField="mediumofadv" HeaderText="mediumofadv" 
                    SortExpression="mediumofadv" />
                <asp:BoundField DataField="refid" HeaderText="refid" SortExpression="refid" />
                <asp:BoundField DataField="jbid" HeaderText="jbid" SortExpression="jbid" ReadOnly="True" Visible="false" />

                 <asp:TemplateField>
                  <InsertItemTemplate>
                   <asp:TextBox ID="advDetails" runat="server" TextMode="MultiLine" ></asp:TextBox>
                  </InsertItemTemplate>
                 </asp:TemplateField>
                <asp:CommandField ShowInsertButton="True" />
            </Fields>
            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <EditRowStyle BackColor="#999999" />
            <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        </asp:DetailsView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:Waleed_orsfinalConnectionString %>" 
            DeleteCommand="DELETE FROM [tblJobAdv] WHERE [advid] = @advid" 
            InsertCommand="INSERT INTO [tblJobAdv] ([advtitle], [startingdate], [endingdate], [mediumofadv], [refid], [jbid]) VALUES (@advtitle, @startingdate, @endingdate, @mediumofadv, @refid, @jbid)" 
            SelectCommand="SELECT * FROM [tblJobAdv]" 
            UpdateCommand="UPDATE [tblJobAdv] SET [advtitle] = @advtitle, [startingdate] = @startingdate, [endingdate] = @endingdate, [mediumofadv] = @mediumofadv, [refid] = @refid, [jbid] = @jbid WHERE [advid] = @advid">
            <DeleteParameters>
                <asp:Parameter Name="advid" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="advtitle" Type="String" />
                <asp:Parameter DbType="Date" Name="startingdate" />
                <asp:Parameter DbType="Date" Name="endingdate" />
                <asp:Parameter Name="mediumofadv" Type="String" />
                <asp:Parameter Name="refid" Type="Int32" />
                <asp:Parameter Name="jbid" Type="Int32" />
                <asp:Parameter Name="advid" Type="Int32" />

            </UpdateParameters>

            <InsertParameters>
                <asp:Parameter Name="advtitle" Type="String" />
                <asp:Parameter DbType="Date" Name="startingdate" />
                <asp:Parameter DbType="Date" Name="endingdate" />
                <asp:Parameter Name="mediumofadv" Type="String" />
                <asp:Parameter Name="refid" Type="Int32" />
                <asp:Parameter Name="advDetails" Type="String" />

                <asp:QueryStringParameter Name="jbid" QueryStringField="jbid" Type="Int32" />
            </InsertParameters>
        </asp:SqlDataSource>

    </div>

    </form>
</body>
</html>

I don't see that field listed in your SQL insert statement.

@jorGem: i am totally confused that from where does this insert statement gets the parameters for insertion in VALUES().
it has pre written parameters like @advTitle, @startingdate,

so from where the insert statement in sqldatasource got these parameters ???? CONFUSED

If you are building the controls using the GUI in Visual Studio, these parameters are being created during hte process when you build the data source during the wizard. You could always go back to the aspx page (source view) and modify it to your needs. Visual Studio will add these parameters When you are on the "Configure Data Source.." wizard and you click on the Advanced tab and enable "Generate Insert, Update, and Delete Statements".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.