<!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 id="Head1" runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Table ID="Table1" runat="server">
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="Label1" runat="server" Text="标题: "></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Width="460px"></asp:TextBox></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="Label2" runat="server" Text="电话: "></asp:Label>
<asp:TextBox ID="TextBox3" runat="server" Width="460px"></asp:TextBox></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="Label3" runat="server" Text="地址: "></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="drl1_SelectedChange"
AutoPostBack="true">
<asp:ListItem Value="0">--省/直辖市--</asp:ListItem>
<asp:ListItem Value="bj">北京市</asp:ListItem>
<asp:ListItem Value="tj">天津市</asp:ListItem>
<asp:ListItem Value="yn">云南省</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList ID="DropDownList2" runat="server">
<asp:ListItem Value="0">--所属城市--</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="TextBox4" runat="server" Width="266px"></asp:TextBox></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine"
Width="500px" Height="300px" Text="详细信息:"></asp:TextBox></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:DropDownList ID="DropDownList3" runat="server">
<asp:ListItem>出售信息</asp:ListItem>
<asp:ListItem>收购信息</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Text="提交" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="返回" OnClick="Button2_Click" /></asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class Default4 : System.Web.UI.Page
{
SqlConnection myConn;
public void Page_Load(object sender, EventArgs e)
{
string myConnString = "server=.\\SQLEXPRESS;database=151;user id=sa;password=tmdjsj"; //连接sql数据库
myConn = new SqlConnection(myConnString);
myConn.Open();
if (Page.IsPostBack)
{
DataBind();
}
}
public void drl1_SelectedChange(object sender, EventArgs e)
{
DropDownList2.Items.Clear();
switch (DropDownList1.SelectedIndex)
{
case 1:
DropDownList2.Items.Add(new ListItem("--请选择--", "0"));
DropDownList2.Items.Add(new ListItem("宣武区", "yggh"));
DropDownList2.Items.Add(new ListItem("海淀区", "ygxm"));
DropDownList2.Items.Add(new ListItem("部门编号", "bmbh"));
DropDownList2.Items.Add(new ListItem("部门名称", "bmmc"));
break;
case 2:
DropDownList2.Items.Add(new ListItem("--请选择--","0"));
DropDownList2.Items.Add(new ListItem("河西区", "0"));
DropDownList2.Items.Add(new ListItem("河东区", "0"));
break;
case 3:
DropDownList2.Items.Add(new ListItem("--请选择--", "0"));
DropDownList2.Items.Add(new ListItem("盘龙区", "0"));
DropDownList2.Items.Add(new ListItem("官渡区", "0"));
break;
}
}
public void Button1_Click(object sender, EventArgs e)
{
int comID = int.Parse(Session["comID"].ToString());
string comName = Session["comName"].ToString();
string buyIndex = TextBox2.Text;
string buyParticular = TextBox1.Text;
SqlCommand cmd = new SqlCommand();
cmd.Connection = myConn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "InsertBuy";
cmd.Parameters.Add("@comID", SqlDbType.Int).Value = comID;
cmd.Parameters.Add("@buycomName", SqlDbType.NVarChar).Value = comName;
cmd.Parameters.Add("@buyIndex", SqlDbType.NVarChar).Value = buyIndex;
cmd.Parameters.Add("@buyParticular", SqlDbType.NVarChar).Value = buyParticular;
cmd.ExecuteNonQuery();
myConn.Close();
Response.Redirect("Default2.aspx");
}
public void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("Default2.aspx");
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default4.aspx.cs" Inherits="Default4" %>
<!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 id="Head1" runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Table ID="Table1" runat="server">
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="Label1" runat="server" Text="标题: "></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" Width="460px"></asp:TextBox></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="Label2" runat="server" Text="电话: "></asp:Label>
<asp:TextBox ID="TextBox3" runat="server" Width="460px"></asp:TextBox></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label ID="Label3" runat="server" Text="地址: "></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="drl1_SelectedChange"
AutoPostBack="true">
<asp:ListItem Value="0">--省/直辖市--</asp:ListItem>
<asp:ListItem Value="bj">北京市</asp:ListItem>
<< 上一页 [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] ... 下一页 >>