将数据从detailsview控件插入数据库 [英] insert data from detailsview control to database

查看:96
本文介绍了将数据从detailsview控件插入数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好先生.
我想将数据从详细信息视图插入数据库.
我带了一个detailsview控件和一些文本框,以及一个按钮.那我该如何将数据保存到数据库.
我的代码如下.
如果有人知道plz helpme.

hello sir.
i want to insert data from details view to database.
i took a detailsview control and some textboxes, and one button. then how can i save the data to database.
my code is below.
if anybody know plz helpme.

<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"

                        DataKeyNames="ProductID" AllowPaging="False" Width="500"

                        EnableViewState="False">
                        <AlternatingRowStyle BackColor="White" />
                        <headerstyle backcolor="Navy" forecolor="White"/>

                        <Fields>

                            <asp:TemplateField HeaderText ="Category-id">
                                <InsertItemTemplate >

                                </InsertItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:TextBox ID="TxtCategoryid" runat="server"></asp:TextBox>
                                    <asp:Label ID="LabelCategoryid" runat="server" ></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText ="Category-description">
                                <InsertItemTemplate >

                                </InsertItemTemplate>
                                <EditItemTemplate>

                                    <asp:Label ID="LabelCategoryid" runat="server" ></asp:Label>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:TextBox ID="TxtCategorydescription" runat="server"></asp:TextBox>
                                    <asp:Label ID="LabelCategorydescription" runat="server" ></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText ="Additional field 1">
                                <InsertItemTemplate >

                                </InsertItemTemplate>
                                <ItemTemplate>
                                    <asp:TextBox ID="TxtAdditionalfield1" runat="server" ></asp:TextBox>
                                    <asp:Label ID="LblAdditionalfield1" runat="server" ></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText ="Additional field 2">
                                <ItemTemplate >
                                    <asp:TextBox ID="TxtAdditionalfield2" runat="server"></asp:TextBox>
                                    <asp:Label ID="LblAdditionalfield2" runat="server" ></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText ="Additional field 3">
                                <ItemTemplate >
                                    <asp:TextBox ID="TxtAdditionalfield3" runat="server"></asp:TextBox>
                                    <asp:Label ID="LblAdditionalfield3" runat="server" ></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText ="Additional field 4">
                                <ItemTemplate >
                                    <asp:TextBox ID="TxtAdditionalfield4" runat="server"></asp:TextBox>
                                    <asp:Label ID="LblAdditionalfield4" runat="server" ></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>

                            <asp:TemplateField >
                                <ItemTemplate>
                                    <asp:Button ID="BtnSave" Text ="Save" runat="server" Width="80"/>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Fields>
                    </asp:DetailsView>

推荐答案

请看以下文章.

GridView-DetailsView(主/详细信息)控件 [ GridView其他功能-DetailsView [
Have a look at the following article.

GridView-DetailsView (Master/Detail) Control[^]

Also this one too. GridView extras - DetailsView[^]


此处有许多示例使用DetailsView:

^ ]
Lots of examples here on how to use a DetailsView:

Google search - detailsview example[^]


这篇关于将数据从detailsview控件插入数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆