我有一個列表視圖,每列有兩個或多個單選按鈕控件,我想查找是否至少有一個單選按鈕被提交。.net listview查找是否至少有一個radiah在eah列中被選中
例如
ROW 1 Quetison 1 radiobutton1 radiobutton2 radiobutton3
ROW 2 Quetison 2 radiobutton1 radiobutton2 radiobutton3
上提交我想findout如果用戶檢查ATLEAST每個ROW上一個單選按鈕
我有一個列表視圖,每列有兩個或多個單選按鈕控件,我想查找是否至少有一個單選按鈕被提交。.net listview查找是否至少有一個radiah在eah列中被選中
例如
ROW 1 Quetison 1 radiobutton1 radiobutton2 radiobutton3
ROW 2 Quetison 2 radiobutton1 radiobutton2 radiobutton3
上提交我想findout如果用戶檢查ATLEAST每個ROW上一個單選按鈕
了一個Asp.Net的ListView:
foreach(ListViewDataItem myItem in myListView.Items)
{
RadioButton btn1 = (RadioButton)myItem.FindControl("radiobutton1");
RadioButton btn2 = (RadioButton)myItem.FindControl("radiobutton2");
RadioButton btn3 = (RadioButton)myItem.FindControl("radiobutton3");
bool AtLeastOneChecked = btn1.Checked || btn2.Checked || btn3.Checked;
}
新方法 - 不知道的單選按鈕#
foreach(ListViewDataItem myItem in myListView.Items)
{
bool AtLeastOneChecked = false;
foreach(Control myControl in myItem.Controls)
{
try
{
RadioButton rdoTemp = (RadioButton)myControl;
AtLeastOneChecked = rdoTemp.Checked;
}
catch (Exception)
{
// do nothing - this probably wasn't a radio button control and errored out onthe conversion
}
}
}
http://stackoverflow.com/questions/1497414/getting - 從一個選定的項目在一個單選項在一個網格視圖中的asp-n/1497511#1497511 –
asp.net listview – nLL