日期:2014-05-17  浏览次数:20997 次

从radiobuttonlist提取text
 if (!IsPostBack)
        {
            SqlConnection cn = new SqlConnection();
            cn.ConnectionString = "server = (local);password = 123;uid = sa;database = keshe";
            cn.Open();
            SqlDataAdapter adp = new SqlDataAdapter("select * from 房屋表 ", cn);
            DataSet ds = new DataSet();
            adp.Fill(ds, "房屋表");
            RadioButtonList1.DataSource = ds.Tables["房屋表"];
            RadioButtonList1.DataTextField = "出租价格";
            RadioButtonList1.DataBind();
            for (int i = 0; i <= RadioButtonList1.Items.Count - 1; i++)
            {
                if (RadioButtonList1.Items[i].Selected)
                {
                    Label2.Text = RadioButtonList1.Items[i].Value;
                }
            }

            string s = "select * from 房屋表 where 出租价格 = '" + Label2.Text + "'";
            SqlDataAdapter da = new SqlDataAdapter(s, cn);
            DataSet ds_1 = new DataSet();
            da.Fill(ds_1, "房屋表");
            GridView1.DataSource = ds_1.Tables["房屋表"];
            GridView1.DataBind();

            cn.Close();
        }