2009-06-27 8 views
1

私はあなたが助けてくれることを願っています。これは数時間私を混乱させてきました。ラジオボタンリストの項目は常にfalseです

私はCustomerGroupConfirm.aspxページにRadioButtonのリストを持っている:私はラジオボタンを選択し、ボタンをIをクリックしたときに、ここで「デフォルトの顧客契約のグループを確認し、」

<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> 

は、関数は、コードビハインドでこれは火災:

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のを結合しています。

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

これは間違いありません。どうもありがとうございます。 –

関連する問題