| 
 | 
 
 
 楼主 |
发表于 2013-5-17 21:50:08
|
显示全部楼层
 
 
 
using System; 
using System.Collections; 
using System.Configuration; 
using System.Data; 
using System.Linq; 
using System.Web; 
using System.Web.Security; 
using System.Web.UI; 
using System.Web.UI.HtmlControls; 
using System.Web.UI.WebControls; 
using System.Web.UI.WebControls.WebParts; 
using System.Xml.Linq; 
using System.Data.SqlClient; 
 
public partial class 订单页1 : System.Web.UI.Page 
{ 
     
 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!IsPostBack) 
        { 
            SqlConnection con = new SqlConnection(@"server=.\sqlexpress;database=stu;trusted_connection=true"); 
            SqlCommand cmd = new SqlCommand(); 
            SqlDataAdapter sda = new SqlDataAdapter(); 
            DataSet ds = new DataSet(); 
 
            sda.SelectCommand =  
   new SqlCommand("select * from Chair,Train where Chair.id= Train.id and Train.id='" + Session["id"].ToString() + "' ", con); 
            sda.Fill(ds); 
 
            DropDownList1.DataTextField = "seat"; 
            DropDownList1.DataValueField = "price"; 
            DropDownList1.DataSource = ds.Tables[0]; 
             
            
            
            
            DropDownList1.DataBind(); 
 
            //ds.Dispose(); 
 
            
        } 
    } 
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        Response.Write("value:" + DropDownList1.SelectedValue);//值为no. 
        Response.Write("no:" + DropDownList1.SelectedIndex); 
    } 
} |   
 
 
 
 |