RadioButtonList问题我的RadioButtonList是绑定数据库的!然后程序的有两个Button 一个提交 一个重置 在重置的时候我不想在调用数据库重新绑定RadioButtonList这样占用很多速度!
应该如何做!
我的代码如下
private void Op_cz_Click(object sender, System.EventArgs e)
{
Op_name.Text = "";
Op_mq.Text = "";
Op_Email.Text = "";
Op_yj.Text = "";
Op_js.Checked = false;
Op_fg.Items[0].Selected = true;  // 这样不管用呀!!
Op_sd.Items[0].Selected = true;
}

解决方案 »

  1.   

    将RadioButtonList的AutoPost属性设置True试下 
      

  2.   

    把代码都贴出来 看看你的pag_load
      

  3.   

    private void Page_Load(object sender, System.EventArgs e)
    {
    if(!IsPostBack)
    {
    SqlConnection con = Data_Operation.OpDataCon.OpCon();
    con.Open(); SqlCommand cmd = new SqlCommand("Opjs_GetList",con);
    cmd.CommandType = CommandType.StoredProcedure; SqlDataReader sdr = cmd.ExecuteReader();
    this.Op_fg.DataSource = sdr;
    this.Op_fg.DataTextField = "Op_js";
    this.Op_fg.DataValueField = "Op_id";
    this.Op_fg.DataBind();
    this.Op_fg.Items[0].Selected = true;
    sdr.Close(); SqlDataReader sda = cmd.ExecuteReader();
    this.Op_sd.DataSource = sda;
    this.Op_sd.DataTextField = "Op_js";
    this.Op_sd.DataValueField = "Op_id";
    this.Op_sd.DataBind();
    this.Op_sd.Items[0].Selected = true;
    sda.Close(); con.Close();
    }
      

  4.   

    this.Op_fg.Items[0].Selected = true;
    this.Op_sd.Items[0].Selected = true;
    这样不管用呀!
      

  5.   

    为啥不用 RadioButtonList.SelectedIndex 属性?
      

  6.   

    先验证 提交的按键, 然后处理是否要绑定.如:
    private bool bBind = true;private void WebPage_PreRender(object sender, EventArgs e)
    {
    if (bBind){....}
    }private void btnBind_Click(object sender, EventArgs e)
    {
    bBind=true;}
    private void btnUnBind_Click(object sender, EventArgs e)
    {
    bBind=false;}注意以上, PreRender 事件理手动添加
    this.PreRender += new System.EventHandler(this.WebPage_PreRender);如果以上信息对各位有用, 谢谢:> 我的急救,征名散分:  http://community.csdn.net/Expert/TopicView1.asp?id=5405222
      

  7.   

    this.Op_fg.SelectedIndex = 0;
    this.Op_sd.SelectedIndex = 0;