2009-06-27 3 views
1

도와 주시면 감사하겠습니다. 이것은 몇 시간 동안 나를 혼란스럽게 만들었다. 라디오 버튼 목록 항목은 항상 거짓입니다.

내 CustomerGroupConfirm.aspx 페이지에 RadioButton 구성 목록을 가지고 :
<div> 
    <table> 
     <tbody> 
      <tr> 
       <td nowrap="nowrap"> 
        <asp:RadioButtonList ID="rblContractGroups" runat="server"></asp:RadioButtonList> 
       </td> 
      </tr> 
      <tr> 
       <td nowrap="nowrap"> 
       <br /> 
        <asp:Button ID="btnConfirmCustomerContractGroups" runat="server" OnClick="confirmCustomerContractGroups_Click" CssClass="Button" Text="Confirm Default Customer Contract Group" /> 
       </td> 
      </tr> 
     </tbody> 
    </table> 
</div> 

내가 RadioButton에 선택하고 I 버튼을 클릭하면 여기에서 함수 코드 숨김이다 "기본 고객 계약 그룹 확인"하는 화재 :

protected void confirmCustomerContractGroups_Click(object sender, EventArgs e) 
{ 
    // Iterate through the Radio Button list. 
    foreach (ListItem li in rblContractGroups.Items) 
    { 
     if (li.Selected) 
     // If the Radio Button List Item (Customer Contract Group) is Selected. 
     { 
      // Set the Default Customer Contract Group of the Current User. 
      CustomerAccess.SetDefaultCustomerContractGroup(Int32.Parse(Session["CustomerID"].ToString()), Int32.Parse(li.Value)); 
     } 
    } 
    Response.Redirect("~/Default.aspx"); 
} 

문제는 목록 항목 (li.Selected)은 항상 false입니다.

내가 뭘 잘못하고 있니? 누구든지 도와주세요.

친절 감사

월터

답변

1

어쩌면 당신은 결합하고 당신의 rblContractGroups 모든 포스트 백에 radiobuttonlist. IsPostBack 컨트롤에 넣어야합니다.

if (!Page.IsPostBack) 
{ 
    // Bind your rblContractGroups 
} 
+0

정말 정확합니다. 정말 고맙습니다. –