包含字段:first name(输入), phone(分3个Textbox输入),states(下拉,从数据库中取得)。
进入页面的时候根据参数id来判断是增加还是修改,id>0是修改,反之增加。特殊要求:
1. *First Name:,必输字段前面有一个红色的*
2. Phone是根据3个输入框输入,然后合并存入数据库的。修改时候显示也要解析之后显示在3个textbox里面。(解析方法已经存在)本人初学,代码越完整越好asp.net2.0(aspx+C#),不胜感激!
进入页面的时候根据参数id来判断是增加还是修改,id>0是修改,反之增加。特殊要求:
1. *First Name:,必输字段前面有一个红色的*
2. Phone是根据3个输入框输入,然后合并存入数据库的。修改时候显示也要解析之后显示在3个textbox里面。(解析方法已经存在)本人初学,代码越完整越好asp.net2.0(aspx+C#),不胜感激!
解决方案 »
- wcf如何限制客户端访问?关键是客户端是纯html+js(其实就是ajax调用wcf)
- |zyciis| 如何清除一个有“控件包含代码块”的子控件,谢谢
- if (!addressOK)是什么意思?谁能帮忙解释下,谢谢
- 控件和打印的问题。。打印出空白页面
- 关于gridview控件 新手问题
- 请教------如何确定gridview中的单元格的位置
- HttpWebRequest.GetRequestStream调用出错
- 水晶报表工具栏的问题
- 问一个数据库生成流水号的问题
- win2000下string类型的数据最长可以有多少个字符?
- 高手来得越来越少,也不知道这个问题能不能解决,唉。搞郁闷了~!
- 上传文件问题,在线!!!
.aspx文件
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Practice_InsertQueryModifyDelete.aspx.cs" Inherits="Practice_InsertQueryModifyDelete" %><!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:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="#336666"
BorderStyle="Double" BorderWidth="1" CellPadding="1" GridLines="both" AutoGenerateColumns="False"
OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowDataBound="GridView1_RowDataBound"
OnRowDeleting="GridView1_RowDeleting" OnSorting="GridView1_Sorting" OnPageIndexChanging="GridView1_PageIndexChanging"
OnSelectedIndexChanging="GridView1_SelectedIndexChanging">
<FooterStyle BackColor="White" ForeColor="#333333" />
<RowStyle BackColor="White" ForeColor="#333333" Font-Size="9pt"/>
<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#336666" Font-Bold="False" ForeColor="White" Font-Size="9pt" Height="30"/>
<Columns>
<asp:CommandField ButtonType="link" ShowSelectButton="True" HeaderText="選定" />
<asp:CommandField ButtonType="link" ShowEditButton="True" HeaderText="修改"/>
<asp:CommandField ButtonType="link" ShowDeleteButton="True" HeaderText="刪除"/>
<asp:TemplateField HeaderText="SupplierID">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("SupplierID") %>' ReadOnly="True" Width="80px"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("SupplierID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CompanyName">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("CompanyName") %>' Width="80px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox2" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("CompanyName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ContactName">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("ContactName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("ContactName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Address") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Address") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("City") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("City") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="White"
BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4"
GridLines="Horizontal" Height="50px" OnItemCommand="DetailsView1_ItemCommand"
OnItemInserting="DetailsView1_ItemInserting" OnModeChanging="DetailsView1_ModeChanging"
OnPageIndexChanging="DetailsView1_PageIndexChanging" Visible="False" Width="125px" OnItemInserted="DetailsView1_ItemInserted">
<FooterStyle BackColor="White" ForeColor="#333333" />
<EditRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="White" ForeColor="#333333" />
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
<Fields>
<asp:BoundField DataField="SupplierID" HeaderText="SupplierID" ReadOnly="True" />
<asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
<asp:BoundField DataField="ContactName" HeaderText="ContactName" />
<asp:BoundField DataField="Address" HeaderText="Address" />
<asp:BoundField DataField="City" HeaderText="City" />
<asp:CommandField ButtonType="Button" ShowInsertButton="True" />
<asp:CommandField ButtonType="Button" ShowEditButton="True" />
<asp:CommandField ButtonType="Button" ShowDeleteButton="True" />
</Fields>
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
</asp:DetailsView>
</div>
</form>
</body>
</html>
.aspx文件
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Practice_InsertQueryModifyDelete.aspx.cs" Inherits="Practice_InsertQueryModifyDelete" %><!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:GridView ID="GridView1" runat="server" BackColor="White" BorderColor="#336666"
BorderStyle="Double" BorderWidth="1" CellPadding="1" GridLines="both" AutoGenerateColumns="False"
OnRowCancelingEdit="GridView1_RowCancelingEdit"
OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowDataBound="GridView1_RowDataBound"
OnRowDeleting="GridView1_RowDeleting" OnSorting="GridView1_Sorting" OnPageIndexChanging="GridView1_PageIndexChanging"
OnSelectedIndexChanging="GridView1_SelectedIndexChanging">
<FooterStyle BackColor="White" ForeColor="#333333" />
<RowStyle BackColor="White" ForeColor="#333333" Font-Size="9pt"/>
<SelectedRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#336666" Font-Bold="False" ForeColor="White" Font-Size="9pt" Height="30"/>
<Columns>
<asp:CommandField ButtonType="link" ShowSelectButton="True" HeaderText="選定" />
<asp:CommandField ButtonType="link" ShowEditButton="True" HeaderText="修改"/>
<asp:CommandField ButtonType="link" ShowDeleteButton="True" HeaderText="刪除"/>
<asp:TemplateField HeaderText="SupplierID">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("SupplierID") %>' ReadOnly="True" Width="80px"></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("SupplierID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CompanyName">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("CompanyName") %>' Width="80px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox2" ErrorMessage="RequiredFieldValidator">*</asp:RequiredFieldValidator>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("CompanyName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ContactName">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("ContactName") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("ContactName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Address") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Address") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("City") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("City") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" BackColor="White"
BorderColor="#336666" BorderStyle="Double" BorderWidth="3px" CellPadding="4"
GridLines="Horizontal" Height="50px" OnItemCommand="DetailsView1_ItemCommand"
OnItemInserting="DetailsView1_ItemInserting" OnModeChanging="DetailsView1_ModeChanging"
OnPageIndexChanging="DetailsView1_PageIndexChanging" Visible="False" Width="125px" OnItemInserted="DetailsView1_ItemInserted">
<FooterStyle BackColor="White" ForeColor="#333333" />
<EditRowStyle BackColor="#339966" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="White" ForeColor="#333333" />
<PagerStyle BackColor="#336666" ForeColor="White" HorizontalAlign="Center" />
<Fields>
<asp:BoundField DataField="SupplierID" HeaderText="SupplierID" ReadOnly="True" />
<asp:BoundField DataField="CompanyName" HeaderText="CompanyName" />
<asp:BoundField DataField="ContactName" HeaderText="ContactName" />
<asp:BoundField DataField="Address" HeaderText="Address" />
<asp:BoundField DataField="City" HeaderText="City" />
<asp:CommandField ButtonType="Button" ShowInsertButton="True" />
<asp:CommandField ButtonType="Button" ShowEditButton="True" />
<asp:CommandField ButtonType="Button" ShowDeleteButton="True" />
</Fields>
<HeaderStyle BackColor="#336666" Font-Bold="True" ForeColor="White" />
</asp:DetailsView>
</div>
</form>
</body>
</html>
SelectCommand="SELECT * FROM client WHERE clientID=@clientID"
InsertCommand="INSERT INTO Client(firstName, lastName, companyName)
VALUES(@firstName, @lastName,@companyName)"
UpdateCommand="UPDATE client SET firstName=@firstName, lastName=@lastName, companyName=@companyName
WHERE clientID=@clientID" >
</asp:SqlDataSource>
类似这种参数应该如何传递啊?