日期:2014-05-18  浏览次数:20401 次

请问如何设置DetailsView来插入SQL?
请问

        <form   id= "form1 "   runat= "server ">
        <div>
                <asp:DetailsView   ID= "DetailsView1 "   runat= "server "   AutoGenerateRows= "False "   DataSourceID= "SqlDataSource1 "
                        Height= "50px "   Width= "125px "     AutoGenerateInsertButton= "true ">
                        <Fields>
                                <asp:BoundField   DataField= "title "   HeaderText= "title "   SortExpression= "title "   />
                                <asp:BoundField   DataField= "content "   HeaderText= "content "   SortExpression= "content "   />
                        </Fields>
                </asp:DetailsView>
                <asp:SqlDataSource   ID= "SqlDataSource1 "   runat= "server "   ConnectionString= " <%$   ConnectionStrings:fenhongConnectionString1   %> "
                        SelectCommand= "SELECT   [title],   [content]   FROM   [news] "   InsertCommand= "INSERT   INTO   news(title,content)   VALUES   () ">
                </asp:SqlDataSource>
        </div>
        </form>

这里的InsertCommand= "INSERT   INTO   news(title,content)   VALUES   () ">

怎么写才能提交表单数据到SQL?

------解决方案--------------------
你在配置数据源SqlDataSource的时候 配置SQL语句选项中 选择 "高级"按纽 生成 insert update ...
就可以了