怎么在第二个页面接收第一个页面里 RadioButtonList所选的值???

解决方案 »

  1.   

    string value = RadioButtonList.SelectedValue;
    Response.Redirect("...aspx?rvalue="+value)
    接收
    Request.QureyString("rvalue");
      

  2.   

    DataTable dt = new DataTable();
                dt = item1.Data_code.Class1.Search("select * from addpp where ppName='" + Request.QueryString["P"] + "'"); ;
                 TextBox2.Text = dt.Rows[0][1].ToString();
                 TextBox3.Text = dt.Rows[0][2].ToString();
               RadioButtonList1.SelectedItem.value=dt.Rows[0][3].ToString();
    划线的部分这样写接收不了值???
    怎么改??
      

  3.   

    SelectedItem是只读的吧???RadioButtonList1.SelectedValue=dt.Rows[0][3].ToString();
     这样就可以了。。
      

  4.   

    RadioButtonList1.SelectedValue=dt.Rows[0][3].ToString();
      

  5.   

    如果你是想根据这个值来确定RedioButtonList被选定的值就使用
    RadioButtonList1.SelectedValue=dt.Rows[0][3].ToString();RadioButtonList1.SelectedItem.value=dt.Rows[0][3].ToString();
    这个是你给选定行赋值,就是先有选定的项,然后再给它赋值
      

  6.   

    添加页面的代码
      protected void Button7_Click(object sender, EventArgs e)//add
            {
                item1.Data_code.Class1.Add("insert into addpp (ppName,jb,tjjb) values ('" + TextBox2.Text + "','" + TextBox3.Text + "','" + RadioButtonList1.SelectedValue + "')");
                Response.Redirect("pinpgl.aspx");
            }
    传值页面的部分代码
     protected void LinkButton2_Click(object sender, EventArgs e)
            {
                int row = ((GridViewRow)((LinkButton)sender).NamingContainer).RowIndex;//获取按钮当前索引
                string str = ((LinkButton)(GridView1.Rows[row].FindControl("LinkButton2"))).Text;//获取索引的数据值
                Response.Redirect("Modifypp.aspx?P=" + str);
            }
    接收页面的代码
     public partial class Modify : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
               if(!IsPostBack)
               {
                DataTable dt = new DataTable();
                dt = item1.Data_code.Class1.Search("select * from addpp where ppName='" + Request.QueryString["P"] + "'"); ;
                 TextBox2.Text = dt.Rows[0][1].ToString();
                 TextBox3.Text = dt.Rows[0][2].ToString();
               RadioButtonList1.SelectedValue=dt.Rows[0][3].ToString();
               }
            }        protected void Button7_Click(object sender, EventArgs e)
            {
                item1.Data_code.Class1.Add("update addpp set ppName='" + TextBox2.Text + "',jb='" +TextBox3.Text + "',tjjb='" +  RadioButtonList1.SelectedValue+ "' where ppName='" + Request.QueryString["p"] +"'");
                Response.Redirect("pinpgl.aspx");
            }
        }
      

  7.   

    这里你等于是给RadioButtonList1了一个默认的选定值
      

  8.   

    这是我修改之后的啊
    但是那什么时候用RadioButtonList1.SelectedItem.value呢?
    有点分不清了
      

  9.   

    我记得当时最早.net framework1.0发布的时候,只有selecteditem.value的方式可以访问,用的是VS2002的IDE,后来.net framework1.1发布的时候,为了方便编程增加一个selectedvalue的属性。这两个用法是一样的。
      

  10.   

    怎么一样了啊?
    我做接收值时就不能用RadioButtonList1.SelectedItem.value啊?只能用另外一种了??
      

  11.   

    他们两个如果在前台页面上有选定的值的话,两个value是一样的
    但是如果RedioButtonList没有选定的时候
    RadioButtonList1.SelectedValue=“a”;
    会把页面上value或者text为a的那项给选上
    但是selecteditem.value就会报错,因为页面没有选定项selecteditem,当然也就不存在value了啊
    表达能力不太好,不知道能明白不
      

  12.   


    public virtual ListItem SelectedItem { get; }public virtual string SelectedValue { get; set; }
      

  13.   

    先找到前一个页面的控件
    RadioButton rdbtn = (RadioButton)this.PreviousPage.FindControl("rbtn1")rbtn1是前一个页面的控件ID