在repeater 的ItemDataBound的事件中,获取绑定列的值

 protected void RpVoteManage_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        RadioButtonList rb = e.Item.FindControl("RadioButtonList1") as RadioButtonList;
        HiddenField hfd = e.Item.FindControl("hfd1") as HiddenField;
      
        
       
        // 方法2
        string jx = DataBinder.Eval(e.Item.DataItem, "Jx").ToString();
        if (jx.Trim().Length > 0)
      {
          rb.SelectedValue = jx;
      
      }

        // 方法1  用隐藏控件绑定值
        //if (hfd.Value.Trim().Length > 0)
        //{

        //  //  rb.SelectedValue = hfd.Value.Trim();
        //      //ListItem lt=new ListItem(hfd.Value,hfd.Value);
        //      //rb.SelectedItem.Selected = lt;
        //}
    }

posted @ 2012-03-24 10:29  甜菜波波  阅读(371)  评论(0编辑  收藏  举报