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

急急急!!!在Repeater中,单选按钮选中以后,但是通过断点调试,单选按钮的checked属性还是为false
在aspx中的代码为      <asp:Repeater ID="Users" runat="server">
    <ItemTemplate>  <h1> 
<asp:Label ID="Label1" runat="server" Text='<%#Eval("Name")%>' >
       <%#Eval("Name")%></asp:Label> 
 <asp:RadioButton ID="rb1" runat="server"  Text="好"   GroupName="1"  />
<asp:RadioButton ID="rb2" runat="server" Text="比较好"   GroupName="1" />
  <asp:RadioButton ID="rb3" runat="server"  Text="一般"   GroupName="1" />
  <asp:RadioButton ID="rb4" runat="server" Text="差"  GroupName="1" />
                </h1></ItemTemplate>
                </asp:Repeater>


 后台代码为 foreach (RepeaterItem item in Users.Items){
                Label lbl = (Label)item.FindControl("Label1");
                RadioButton rdo1 = (RadioButton)item.FindControl("rb1");
                RadioButton rdo2 = (RadioButton)item.FindControl("rb2");
                RadioButton rdo3 = (RadioButton)item.FindControl("rb3");
                RadioButton rdo4 = (RadioButton)item.FindControl("rb4");  
} 我通过断点调试以后,rdo1的checked属性一直为false
在线等。。。。。

------解决方案--------------------
if(!isXXXX)
{}
------解决方案--------------------
if(!IsPostback)
{
Users.DataSource//数据源绑定放在!IsPostback里面
}