2009-02-19 18 views
0

我有包含單選按鈕和複選框的datalist。如果我選擇其中一些,然後重定向到另一個aspx頁面。當我到達上一頁時,必須選擇datalist中的單選按鈕和複選框。我在會話變量中選擇了數據。如何使用c#來做到這一點。在c中加載事件保留datalist數據#

+0

\t \t \t \t \t \t \t%#的eval( 「數據」)%>
Yogini 2009-02-19 12:00:05

+0

並且我將數據變量保存爲html,如 - data + =「」+ val +「」; – Yogini 2009-02-19 12:00:52

回答

2

使用ItemDataBound事件我會檢索單選按鈕,比較它的價值,你的Session變量

是這樣的:

protected void MyDataList_ItemDataBound(object sender, DataListItemEventArgs e) 
{ 
    RadioButton myRadioButton = e.Items.FindControl("myRadioButton") as RadioButton; 

    if (myRadioButton == null) { } 
    else 
    { 
     if (string.IsNullOrEmpty(Session[myRadioButton.Value])) {} 
     else myRadioButton.Checked = true;   
    } 
}