想要显示多个列,但我只能显示一个

时间:2013-07-02 19:03:10

标签: asp.net

String CS = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    using (SqlConnection cn = new SqlConnection((CS)))
    {
        SqlCommand cmd = new SqlCommand("select * from Region", cn);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet1 tds = new DataSet1();
        Int32 k=Convert.ToInt32(DropDownList1.Text);

        da.Fill(tds, tds.Tables[0].TableName);
        Label1.Text = Convert.ToString(tds.Region[k].RegionID);
        Label2.Text = Convert.ToString(tds.Region[k].RegionDescription);

        DropDownList1.DataSource = tds;
        DropDownList1.DataBind();
    }

0 个答案:

没有答案