从radiobuttonlist提取text

tt涛涛 2013-12-09 04:26:52
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();
}
...全文
93 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
tt涛涛 2013-12-09
  • 打赏
  • 举报
回复
好吧,谢谢你的帮助
天齐贺少 2013-12-09
  • 打赏
  • 举报
回复
至于一闪就没有了,调试你的load事件。或则其他地方有没有清除或则重置 GridView1 自己试吧
天齐贺少 2013-12-09
  • 打赏
  • 举报
回复
方法就是这样了,我只能告诉你,这样做肯定能做出来,至于哪里不行。呵呵,摸,慢慢摸。
tt涛涛 2013-12-09
  • 打赏
  • 举报
回复
就闪一下然后就没了
tt涛涛 2013-12-09
  • 打赏
  • 举报
回复
#4给的代码和方法我试了,但是无法选中radiobutton
wind_cloud2011 2013-12-09
  • 打赏
  • 举报
回复
http://www.cnblogs.com/LifeKingcn/archive/2012/12/19/2825120.html
天齐贺少 2013-12-09
  • 打赏
  • 举报
回复
给radiobuttonlist加SelectedIndexChanged会吧!! 然后在设置AutoPostBack设置为true 会吧 在 protected void RadioButtonListID_SelectedIndexChanged(object sender, EventArgs e) { //自己定义cn string s = "select * from 房屋表 where 出租价格 = '" + RadioButtonList1.SelectedValue + "'"; SqlDataAdapter da = new SqlDataAdapter(s, cn); DataSet ds_1 = new DataSet(); da.Fill(ds_1, "房屋表"); GridView1.DataSource = ds_1.Tables["房屋表"]; GridView1.DataBind(); }
tt涛涛 2013-12-09
  • 打赏
  • 举报
回复
怎样写?给个代码呗
天齐贺少 2013-12-09
  • 打赏
  • 举报
回复
这题,不知道你看懂没,反正我是微懂了!!! 点击radiobuttonlist获取对应信息,然后显示在gridview中 应该在radiobuttonlist的SelectedIndexChanged中写方法,让后讲AutoPostBack设置为true 怎么会写到Load事件上!!!
tt涛涛 2013-12-09
  • 打赏
  • 举报
回复
问题补充: 不能实现,在网页里点击获取的radiobuttonlist所获取的按钮,无法使其对应的数据库信息显示在gridview中

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧