2013-05-09 48 views

回答

1

只要您知道該值在列表中(如果它不在列表中,那麼當該行執行時會得到一個異常),您可以簡單地通過RadioButtonList.SelectedValue = reader.value;分配值。

因爲聽起來好像你並不確定reader.value將會是RadioButtonList中的一個選項,所以你需要首先檢查。

if(RadioButtonList.Items.FindByValue(reader.value) != null) { 
    RadioButtonList.SelectedValue = reader.value; 
} 

或者,您可以通過try/catch處理異常。

+0

其實,RadioButtonlist.value是硬編碼。數據庫只存儲文本。因此不能使用rdb.selectedvalue = reader.value – 2013-05-10 01:47:49

0
string sSortname = row["GoodsSortName"].ToString().Trim(); 
     foreach (ListItem s in this.rdbSort.Items) 
     { 
      if (s.Text == sSortname) 
      { 
       s.Selected = true; 
       break; 
      } 

     } 

我用這個辦法,只好求解帶這個問題

相關問題